If this is your first visit, be sure to check out the FAQ by clicking the link above. You may have to register before you can post: click the register link above to proceed. To start viewing messages, select the forum that you want to visit from the selection below.

 
Go Back  dBforums > Database Server Software > DB2 > insert into generated (identiry) column

Reply
 
LinkBack Thread Tools Search this Thread Display Modes
  #1 (permalink)  
Old 02-15-05, 10:27
jfkuser jfkuser is offline
Registered User
 
Join Date: Mar 2003
Posts: 59
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
Reply With Quote
  #2 (permalink)  
Old 02-15-05, 11:40
urquel urquel is offline
Registered User
 
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.
Reply With Quote
  #3 (permalink)  
Old 02-15-05, 17:47
jfkuser jfkuser is offline
Registered User
 
Join Date: Mar 2003
Posts: 59
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
Reply With Quote
  #4 (permalink)  
Old 02-16-05, 02:38
sathyaram_s sathyaram_s is offline
Super Moderator
 
Join Date: Aug 2001
Location: UK
Posts: 4,534
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.
Reply With Quote
Reply

Thread Tools Search this Thread
Search this Thread:

Advanced Search
Display Modes

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is Off
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are On