Page 1 of 1

insert a db2 sequence generated value

Posted: Wed Jan 17, 2007 2:17 am
by ajmore
Hi all :) ,

I have to insert a db2 sequence generated value into a field for a table(say ABC),the sequence name is IA.INDIV_EN_ID_SEQ


INSERT INTO #TgtDB#.ABC
(IDENTITY_ID, INDIVIDUAL_ENTITY_ID)
VALUES
(ORCHESTRATE.IDENTITY_ID, NEXTVAL FOR IA.INDIV_EN_ID_SEQ)

But while doing this i am getting the following error

An unexpected token "NEXT" was found following "L_ENTITY_ID = SELECT". Expected tokens may include: "WHERE". SQLSTATE=42601.

Is this the proper method to insert seq. generated value in a Col.?? :?:

Re: insert a db2 sequence generated value

Posted: Wed Jan 17, 2007 4:37 am
by vivekreddy
ajmore wrote:Hi all :) ,

I have to insert a db2 sequence generated value into a field for a table(say ABC),the sequence name is IA.INDIV_EN_ID_SEQ


INSERT INTO #TgtDB#.ABC
(IDENTITY_ID, INDIVIDUAL_ENTITY_ID)
VALUES
(ORCHESTRATE.IDENTITY_ID, NEXTVAL FOR IA.INDIV_EN_ID_SEQ)

But while doing this i am getting the following error

An unexpected token "NEXT" was found following "L_ENTITY_ID = SELECT". Expected tokens may include: "WHERE". SQLSTATE=42601.

Is this the proper method to insert seq. generated value in a Col.?? :?:
There wouldn't be any select clause; take the value directly from the said sequence.