Results 1 to 4 of 4

Thread: Error!! Help?

  1. #1
    Join Date
    Jun 2002
    Posts
    2

    Unanswered: Error!! Help?

    I'm trying to create an identity column in a DB2 table. I want the DB2 to assign a unique sequential number to each record that's added to the table. When I make a new table and create a field called "Numberkey", I set it as "Identity" with an initial value of 1 and increment of 1. I also checked the "by default" box. However, when I press "ok" to store the table, it gives me this error:

    [IBM][CLI Driver][DB2/NT] SQL0104N An unexpected token "BY DEFAULT AS IDENTITY (START WIT" was found following "NOT NULL GENERATED". Expected tokens may include: "<references_spec>". SQLSTATE=42601

    Anyone know how to fix this? Thanks so much in advance.
    Vicky

  2. #2
    Join Date
    May 2002
    Location
    Pune, India
    Posts
    23
    vixydish,

    db2 "create table tr1(a int not null generated by default as identity(start with 1, increment by 1))
    DB20000I The SQL command completed successfully.

    Works fine for me..
    What exact command are you using?

    Regards
    sumeet

  3. #3
    Join Date
    Aug 2001
    Location
    UK
    Posts
    4,650

    Re: Error!! Help?

    Which version of DB2 are you ....

    Check the manuals corresponding to your version to see whether identity columns are supported ...

    Cheers

    Sathyaram

    Originally posted by vixydish
    I'm trying to create an identity column in a DB2 table. I want the DB2 to assign a unique sequential number to each record that's added to the table. When I make a new table and create a field called "Numberkey", I set it as "Identity" with an initial value of 1 and increment of 1. I also checked the "by default" box. However, when I press "ok" to store the table, it gives me this error:

    [IBM][CLI Driver][DB2/NT] SQL0104N An unexpected token "BY DEFAULT AS IDENTITY (START WIT" was found following "NOT NULL GENERATED". Expected tokens may include: "<references_spec>". SQLSTATE=42601

    Anyone know how to fix this? Thanks so much in advance.
    Vicky

  4. #4
    Join Date
    Jun 2002
    Posts
    2
    Hi sumeet,

    I'm not really familiar with DB2, so I'm not sure what you mean by "command." I'm not typing in any actual code. The product I use is:

    IBM DB2 Universal Database
    Version 7

    I go to the Control Center, log in, and create a new table. Under the "Columns" tab, I click on the button "Add" to add a new column called "Numberkey." I set the datatype to Integer and click on the check box that says "Generate Column Contents." The "Nullable" checkbox becomes uneditable after I click on the "Generate Column Contents" checkbox. Then I click on the "Identity" radio button and set the initial value and increment value. I press "ok" and it lets me. Then when I click "ok" to save the table, it generates the error below.

    Any other ideas?
    Thank you so much!


    Originally posted by sumeet_db2
    vixydish,

    db2 "create table tr1(a int not null generated by default as identity(start with 1, increment by 1))
    DB20000I The SQL command completed successfully.

    Works fine for me..
    What exact command are you using?

    Regards
    sumeet

Posting Permissions

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