Accessing Sequences in Tranformer stage

Post questions here relative to DataStage Server Edition for such areas as Server job design, DS Basic, Routines, Job Sequences, etc.

Moderators: chulett, rschirm, roy

Post Reply
Murali4u
Participant
Posts: 37
Joined: Sun Feb 21, 2010 12:27 pm

Accessing Sequences in Tranformer stage

Post by Murali4u »

Hi everyone,
I have one requirement.. I have created a sequence command in DB2 and I need to generate a running sequence no using the sequence option and to call it in transformer stage. Can anybody say how to pass the query and do the exercise.

Note:
I'm aware of system variables and how to use the stage variables to handle the sequence no.
Rockzz Tech
chulett
Charter Member
Charter Member
Posts: 43085
Joined: Tue Nov 12, 2002 4:34 pm
Location: Denver, CO

Post by chulett »

Lookup.
-craig

"You can never have too many knives" -- Logan Nine Fingers
chulett
Charter Member
Charter Member
Posts: 43085
Joined: Tue Nov 12, 2002 4:34 pm
Location: Denver, CO

Post by chulett »

OK... I deleted the private message I got asking for clarification on this so I don't recall exactly what you needed to know or were unsure about. If you still need some help, post back here with whatever questions you have and we'll see about getting you some answers.
-craig

"You can never have too many knives" -- Logan Nine Fingers
DSguru2B
Charter Member
Charter Member
Posts: 6854
Joined: Wed Feb 09, 2005 3:44 pm
Location: Houston, TX

Post by DSguru2B »

Lookup is one option where the db2 stage will refer to you sequence obj and the sql will say something like

Code: Select all

SELECT NEXT VALUE FOR SeqObjName, 'X' FROM SYSIBM.SYSDUMMY1;
where 'X' is your dummy key.

Or if your source is a db2 table then you can add an extra column called "SN" and put the following in the derivation

Code: Select all

(NEXT VALUE FOR SeqObjName) AS SN
The latter option is much more efficient.
Creativity is allowing yourself to make mistakes. Art is knowing which ones to keep.
chulett
Charter Member
Charter Member
Posts: 43085
Joined: Tue Nov 12, 2002 4:34 pm
Location: Denver, CO

Post by chulett »

Hmmm... shouldn't need a dummy or any kind of key at all, in fact. And that works in the derivation? Interesting as I've always fallen back on 'user-defined' sql without mentioning that column in the stage and then added something akin to that to whatever the stage generated.
-craig

"You can never have too many knives" -- Logan Nine Fingers
Post Reply