Using database sequence
Moderators: chulett, rschirm, roy
Using database sequence
I have a DB2 sequence created in database.I want that to be used in my target DB2 API stage (like NEXTVAL FOR MYSCHEMA.X_SEQ).Can I do that?
-
- Participant
- Posts: 54607
- Joined: Wed Oct 23, 2002 10:52 pm
- Location: Sydney, Australia
- Contact:
By 'User defined SQL', do you mean Custom SQL, then thats what I am trying.
Seq File -> Trnsfrm -> DB2 API (table TEST1)
TEST1 table contains columns id,name
I am generatng id through DB2 sequence and need to bring name from input.
Will my custom SQL inside DB2 API look like this
insert into MYSCHEMA.TEST1 values(NEXTVAL FOR MYSCHEMMA.X_SEQ,?)
But then again 1st column is showing unmapped in Transformer.
Seq File -> Trnsfrm -> DB2 API (table TEST1)
TEST1 table contains columns id,name
I am generatng id through DB2 sequence and need to bring name from input.
Will my custom SQL inside DB2 API look like this
insert into MYSCHEMA.TEST1 values(NEXTVAL FOR MYSCHEMMA.X_SEQ,?)
But then again 1st column is showing unmapped in Transformer.
Delete the column id and use the below query.
Code: Select all
INSERT INTO MYSCHEMA.TEST1 (id,name) VALUES (NEXTVAL FOR MYSCHEMMA.X_SEQ,:1)
Narasimha Kade
Finding answers is simple, all you need to do is come up with the correct questions.
Finding answers is simple, all you need to do is come up with the correct questions.
-
- Participant
- Posts: 54607
- Joined: Wed Oct 23, 2002 10:52 pm
- Location: Sydney, Australia
- Contact:
The Transformer stage output link must have only one column (name). It must not output the id column. That way, name will align with the :1 parameter marker (the first parameter).
IBM Software Services Group
Any contribution to this forum is my own opinion and does not necessarily reflect any position that IBM may hold.
Any contribution to this forum is my own opinion and does not necessarily reflect any position that IBM may hold.
Ray & Narasimha,
I did the way you mentioned.Transformer output only name (and not id).Within DB2 API, I am generating the id using the sequence
INSERT INTO MYSCHEMA.TEST1 (id,name) VALUES (NEXTVAL FOR MYSCHEMMA.X_SEQ,:1)
But since Column definition in DB2 API contains only 'name', so writing the above SQL gives mismatch of metadata.
DB2_UDB_API_2,0: Fatal Error: Fatal: This SQL statement did not contain the same number of parameters as columns on this link. This usually happens with user-defined SQL.
I did the way you mentioned.Transformer output only name (and not id).Within DB2 API, I am generating the id using the sequence
INSERT INTO MYSCHEMA.TEST1 (id,name) VALUES (NEXTVAL FOR MYSCHEMMA.X_SEQ,:1)
But since Column definition in DB2 API contains only 'name', so writing the above SQL gives mismatch of metadata.
DB2_UDB_API_2,0: Fatal Error: Fatal: This SQL statement did not contain the same number of parameters as columns on this link. This usually happens with user-defined SQL.
-
- Premium Member
- Posts: 783
- Joined: Mon Jan 16, 2006 10:17 pm
- Location: Sydney, Australia