How to get sequence number in Datastage

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
xinhuang66
Participant
Posts: 161
Joined: Wed Aug 02, 2006 4:30 am

How to get sequence number in Datastage

Post by xinhuang66 »

I am talking about Datastage Server, not the parallel server..

There is an API routine KeyMgtGetNextValue, which can help us to generate a sequence number ..

Do you guys usually use it to generated sequence number ?

by the way, If I don't want to start from 0, for example I want to start from a certain point like 1000000. Does KeyMgtGetNextValue can help me ?

Or the only way is to write my personal routine ...

Thanks.
ray.wurlod
Participant
Posts: 54607
Joined: Wed Oct 23, 2002 10:52 pm
Location: Sydney, Australia
Contact:

Post by ray.wurlod »

The two SDK routines KeyMgt... manage generation of sequence numbers by keeping each sequence name as a record in a hashed file called SDKSequences, which is automatically created as necessary.

Sequences in SDKSequences can be initialized with simple INSERT or UPDATE statements, or with a routine. Search the forum for examples.

Another way to maintain a sequence is, of course, to use a sequence or a serial data type in the database during the load phase. Again, search the forum for explicit techniques.
IBM Software Services Group
Any contribution to this forum is my own opinion and does not necessarily reflect any position that IBM may hold.
mint_ag
Participant
Posts: 3
Joined: Tue Jan 30, 2007 11:14 pm
Location: Mumbai

Re: How to get sequence number in Datastage

Post by mint_ag »

I tried both the function given in SDK, but every time I run the job it starts from the next value. Means if in the last job it ends at 20 then it will start from 21. For some jobs I want it to restart from 1. How can I do that? :?:
!! Ashutosh G !!
narasimha
Charter Member
Charter Member
Posts: 1236
Joined: Fri Oct 22, 2004 8:59 am
Location: Staten Island, NY

Post by narasimha »

Welcome Aboard!

The answer is in Ray's reply.
ray.wurlod wrote:Sequences in SDKSequences can be initialized with simple INSERT or UPDATE statements, or with a routine. Search the forum for examples.
Narasimha Kade

Finding answers is simple, all you need to do is come up with the correct questions.
ray.wurlod
Participant
Posts: 54607
Joined: Wed Oct 23, 2002 10:52 pm
Location: Sydney, Australia
Contact:

Post by ray.wurlod »

You can set up a job parameter with the start value, and simply add the value if @OUTROWNUM to it. This is an alternative to using the SDK routines.

Search the forum; there are detailed instructions on initializing a sequence in SDKSequences.
Last edited by ray.wurlod on Wed Jan 31, 2007 2:56 pm, edited 1 time in total.
IBM Software Services Group
Any contribution to this forum is my own opinion and does not necessarily reflect any position that IBM may hold.
DSguru2B
Charter Member
Charter Member
Posts: 6854
Joined: Wed Feb 09, 2005 3:44 pm
Location: Houston, TX

Post by DSguru2B »

Give different argument for different jobs (atleast for different tables) for the Key Management routines. This way you will not mess up the keys and confuse them. There are ways of updating the SDKSequences file and as advised, search the forum for more details. What I like to do is keep the control in my hands. I do a select max(id) from table. Store the value in a hashed file. Access that file in my transformer and generate keys for each incoming row. Even that method is discussed before. A simple search will reveal it all.
Creativity is allowing yourself to make mistakes. Art is knowing which ones to keep.
kduke
Charter Member
Charter Member
Posts: 5227
Joined: Thu May 29, 2003 9:47 am
Location: Dallas, TX
Contact:

Post by kduke »

You need my reseed job that is a part of EtlStats.
Mamu Kim
Post Reply