Results 1 to 2 of 2
  1. #1
    Join Date
    Jan 2003
    Location
    Germany
    Posts
    14

    Unanswered: IDENTITY column in typed table?

    I am trying to get a generated identity column in a typed table.
    According to SQL ref I can specify any <column-options> in the WITH OPTIONS clause. That would include the <generated-column-spec>

    Thats what I am doing:

    CREATE TYPE library.test_t AS (
    id integer,
    testchar varchar(255)
    ) MODE DB2SQL;


    CREATE TABLE library.test2 OF library.test_t (
    id WITH OPTIONS GENERATED ALWAYS AS IDENTITY (START WITH 1, INCREMENT BY 1) NOT NULL PRIMARY KEY,
    );

    When I try to create the table that way, it says something like "GENERATED" is followed by an unexpected token
    "ALWAYS AS IDENTITY (START WITH".
    Where is my mistake?

    Or is it simply not possible to use IDENTITY columns with typed tables?

  2. #2
    Join Date
    Jan 2003
    Location
    Germany
    Posts
    14
    Copied the wrong (and definitely not working CREATE TABLE statement). That should do better:


    CREATE TABLE library.test OF library.test_t (
    REF IS OID user generated,
    id WITH OPTIONS NOT NULL PRIMARY KEY GENERATED ALWAYS AS IDENTITY
    );

    That one works if I leave out tge generated-part.
    The fact that I have to supply my own OID or use those workarounds recommended in the docs is another minor issue.

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •