Results 1 to 4 of 4
  1. #1
    Join Date
    Mar 2003
    Posts
    60

    Unanswered: insert into generated (identiry) column

    Hi all,

    This is ver 8.1 on aix 5.2

    We have 2 tables with following description

    Table A
    col1 integer - identiry column - generated always
    col2 varchar (100)
    col3 char(20)

    Table B
    col1 integer - identiry column - generated always
    col2 varchar (50)

    Table A is new and empty.

    When I try to insert data in table A from tables B using following command I get error :

    Insert into A (col1,col2) select col1, col2 from table b

    SQL0798N A value cannot be specified for column "TSK_SEQ_ID" which is defined
    as GENERATED ALWAYS. SQLSTATE=428C9

    We want to retain col1 values in table B when we insert into table A.

    Is there any way we can do this using this insert?

    Thanks,
    j

  2. #2
    Join Date
    Aug 2004
    Posts
    330
    Try using GENERATED BY DEFAULT instead of GENERATED ALWAYS if you want to be able to provide a value for the IDENTITY column.

  3. #3
    Join Date
    Mar 2003
    Posts
    60

    Thumbs up

    It worked by changing it to generated by default.
    How do i change it back to generated always? I tried "alter table" statement, but might be missing exact syntax.

    Can anyone paste exact command to alter the table from generated default to generated always?

    Thanks,
    j

  4. #4
    Join Date
    Aug 2001
    Location
    UK
    Posts
    4,650
    You can alter a generated column definition only in v8.2

    Cheers
    Sathyaram
    Visit the new-look IDUG Website , register to gain access to the excellent content.

Posting Permissions

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