Generate the Unique Sequence ID

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
rkumar28
Participant
Posts: 43
Joined: Tue Mar 30, 2004 9:39 am

Generate the Unique Sequence ID

Post by rkumar28 »

Hi,

How do we generate the Unique ID like (1,2,3....) for every row inserted in RDBMS using DataStage.

Thanks
harshkohli
Participant
Posts: 31
Joined: Wed Feb 04, 2004 2:04 pm
Location: Canada

Post by harshkohli »

You can use system variable @OUTROWNUM for generating a unique ID.
First store the max(seq_id_column_name from the table) to a variable say var1 and then use var1+ @OUTROWNUM in the mapping.
Harsh Kohli
RamonaReed
Participant
Posts: 26
Joined: Fri Feb 27, 2004 7:23 am
Location: WI, USA

Post by RamonaReed »

You can use KeyMgtGetNextValue or KeyMgtGetNextValueConcurrent depending on whether you have mutiple processes using the same sequence key, and then if you need to re-set the keys, you can use a command stage with the following command: UPDATE SDKSequences USING DICT VOC SET F1 = '1' WHERE @ID = 'your key name';
rkumar28
Participant
Posts: 43
Joined: Tue Mar 30, 2004 9:39 am

Starting the Unique Id from 1268264 instead of from 1

Post by rkumar28 »

Hi,
Is there a way to start the UniqueId from 1268265 rather than from one using KeyMgtGetNextValue.

Thanks
RamonaReed wrote:You can use KeyMgtGetNextValue or KeyMgtGetNextValueConcurrent depending on whether you have mutiple processes using the same sequence key, and then if you need to re-set the keys, you can use a command stage with the following command: UPDATE SDKSequences USING DICT VOC SET F1 = '1' WHERE @ID = 'your key name';
chulett
Charter Member
Charter Member
Posts: 43085
Joined: Tue Nov 12, 2002 4:34 pm
Location: Denver, CO

Post by chulett »

Your quote holds the answer. Simply change the F1 = '1' part to F1 = '1268265' and you are set.
-craig

"You can never have too many knives" -- Logan Nine Fingers
raviyn
Participant
Posts: 57
Joined: Mon Dec 16, 2002 6:03 am

Post by raviyn »

Think that Sequence Id is better if created at the DataBase level...
Need to be careful if there is any sort of migration , as these conditions are easily handled at the RDBMS level
chulett
Charter Member
Charter Member
Posts: 43085
Joined: Tue Nov 12, 2002 4:34 pm
Location: Denver, CO

Post by chulett »

Granted. But there are times when there isn't either the time or the inclination to quote Chapter & Verse on the subject of Better Ways and we simply... answer the question asked.

Besides, I'd rather leave that to Ken most of the time. He's so darn good at it! :wink:
-craig

"You can never have too many knives" -- Logan Nine Fingers
raviyn
Participant
Posts: 57
Joined: Mon Dec 16, 2002 6:03 am

Post by raviyn »

Right, I think I should have Posted with a comment saying suggestion :)
evanmaas
Charter Member
Charter Member
Posts: 60
Joined: Tue Apr 22, 2003 5:19 am
Location: Belgium

Post by evanmaas »

raviyn wrote:Think that Sequence Id is better if created at the DataBase level...
Need to be careful if there is any sort of migration , as these conditions are easily handled at the RDBMS level
This is right.
Generate a unique sequence in the RDMS. This is use over the different DS projects
Example Orqacle: create a sequence #Sequence_Name#, after that you use this user defines sq voor a new value:
SELECT #Sequence_Name#.NEXTVAL FROM DUAL

Regards,

Erik
Post Reply