Doubt regarding surrogate key.

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
rishabh
Participant
Posts: 24
Joined: Mon Apr 10, 2006 11:40 pm

Doubt regarding surrogate key.

Post by rishabh »

Hi everyone,

I am working on Datastage 7.5.1 server version running on Unix with DB2 database.DS Client is on windows XP.

When i use the inbuilt fuction KeyMgtGetNextValue(%dummy%) in order to generate a surrogate key, it works fine.For example for 5 records the last key generated is 5.

However when i run the job again, the next key that is generated is 6 onwards and it does not reset the value and assign the key value 1.

I would like to know how will i be able to reset the value of the surrogate key in the memory.Is there some function which would help me in this regard?

Thanks in advance.
Cheers!
balajisr
Charter Member
Charter Member
Posts: 785
Joined: Thu Jul 28, 2005 8:58 am

Post by balajisr »

chulett
Charter Member
Charter Member
Posts: 43085
Joined: Tue Nov 12, 2002 4:34 pm
Location: Denver, CO

Post by chulett »

If you want it to start from 1 each time, there's absolutely no reason to use that function. Why not simply use @INROWNUM for the surrogate?
-craig

"You can never have too many knives" -- Logan Nine Fingers
raoraghunandan
Charter Member
Charter Member
Posts: 19
Joined: Sun Jul 20, 2003 4:29 am

Re: Doubt regarding surrogate key.

Post by raoraghunandan »

rishabh wrote:Hi everyone,

I am working on Datastage 7.5.1 server version running on Unix with DB2 database.DS Client is on windows XP.

When i use the inbuilt fuction KeyMgtGetNextValue(%dummy%) in order to generate a surrogate key, it works fine.For example for 5 records the last key generated is 5.

However when i run the job again, the next key that is generated is 6 onwards and it does not reset the value and assign the key value 1.

I would like to know how will i be able to reset the value of the surrogate key in the memory.Is there some function which would help me in this regard?

Thanks in advance.
Cheers!
Can I ask, why you need to worry about the surrogate key values ? What is the problem if the surrogate key value is not reset to 1 ?

Thanks,
Raghu
gateleys
Premium Member
Premium Member
Posts: 992
Joined: Mon Aug 08, 2005 5:08 pm
Location: USA

Re: Doubt regarding surrogate key.

Post by gateleys »

I don't see any reason why you would need to reset your surrogate key. But, if you are using it more like a sequence, then follow Craig's suggestion with @INROWNUM. If, you still feel the need to reset it, do a search on "UPDATE SDKSequences".

gateleys
Post Reply