Page 1 of 1

Logic for DB2 sequence develop in Data stage

Posted: Wed Sep 08, 2010 12:40 am
by n.parameswara.reddy@accen
CREATE SEQUENCE STEVE.SEQ_KEY_ACCTS
AS INTEGER
START WITH 1
INCREMENT BY 1;

CREATE TABLE STEVE.TESTSEQ LIKE NEG085_20090210.ACCOUNT;

INSERT INTO STEVE.TESTSEQ
SELECT * FROM NEG085_20090210.ACCOUNT ORDER BY SRC_SYS_ACCT_KEY FETCH FIRST 10 ROWS ONLY;

ALTER table STEVE.TESTSEQ ADD COLUMN NEW_SRC_SYS_ACCT_KEY INTEGER;

UPDATE STEVE.TESTSEQ SET NEW_SRC_SYS_ACCT_KEY = nextval for STEVE.SEQ_KEY_ACCTS;


Can any one help us regarding above logic for DB2 sequence develop in Datastage


Advance thanks for your help
Thanks
PARAM

Posted: Wed Sep 08, 2010 1:59 am
by ray.wurlod
The DDL pieces can be done in Before-SQL.
The DataStage job should select the first 10 rows and pass these through to an INSERT statement.
Create the key column up front and include the reference to the sequence within user-defined SQL.