Surrogate Key generation

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
dwandbi
Participant
Posts: 29
Joined: Sat Feb 04, 2006 6:17 pm

Surrogate Key generation

Post by dwandbi »

Once a surrogate key is generated on an out row for a column, is this keeps on increasing even if we delete all data and reload.

Is there any way if we can generate from starting number after deleting all data from target table?

thanks,
tom
amsh76
Charter Member
Charter Member
Posts: 118
Joined: Wed Mar 10, 2004 10:58 pm

Post by amsh76 »

You can always reset the value of your key. So you can set any value you want, you can go back to one as well.

Simplest thing to do, is to have a process, which will find out the Max value of ID column. This value then in turn can be used to reset the SK.

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

Post by ray.wurlod »

How, exactly, are you generating the value? The mechanism for resetting the sequence will differ depending on your answer.

Of course, if it's a surrogate key the actual value is irrelevant; all a surrogate key provides is uniqueness.
IBM Software Services Group
Any contribution to this forum is my own opinion and does not necessarily reflect any position that IBM may hold.
dwandbi
Participant
Posts: 29
Joined: Sat Feb 04, 2006 6:17 pm

How can this be done

Post by dwandbi »

How to reset SK value?

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

Post by chulett »

As noted, depends on how it is being generated.
-craig

"You can never have too many knives" -- Logan Nine Fingers
dwandbi
Participant
Posts: 29
Joined: Sat Feb 04, 2006 6:17 pm

Still Doubt

Post by dwandbi »

I am generating using KeyMgtGetNextValue(%Sequence Name%).
So if I delete all rows in target table, and run with source data. How to reset SK ID to start from id=1.

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

Post by chulett »

Search is your friend! :wink: I got 13 hits when searching for all words and 'reset KeyMgtGetNextValue'. Many of them have the actual reset syntax in them.
-craig

"You can never have too many knives" -- Logan Nine Fingers
gateleys
Premium Member
Premium Member
Posts: 992
Joined: Mon Aug 08, 2005 5:08 pm
Location: USA

Post by gateleys »

You can use the UPDATE SDKSequences directly in the Administrator command, or get its content via a hashed file with 2 columns (SequenceName as key and NextValue). Then perform the update in Transformer against the Sequence Name.

gateleys
Post Reply