How to Reset Surrogate Key ?

Post questions here relative to DataStage Enterprise/PX Edition for such areas as Parallel job design, Parallel datasets, BuildOps, Wrappers, etc.

Moderators: chulett, rschirm, roy

Post Reply
nraj
Participant
Posts: 15
Joined: Tue Feb 22, 2005 9:22 am

How to Reset Surrogate Key ?

Post by nraj »

Hi

Is there any DS-commond line query to reset Surrogate Key ?

Thanks
ArndW
Participant
Posts: 16318
Joined: Tue Nov 16, 2004 9:08 am
Location: Germany
Contact:

Post by ArndW »

Which surrogate key are you talking about? If you are referring to a Database's internal one then no, there is direct command to do so, you need to issue an SQL call.

If you are talking about the DataStage generated keys using the KeyMgtGetNextValue then yes, there is a way to reset this key; the values are stored in a file called SDKSequences and the key to this file is the name you supply the routine for the sequence. If you remove this record then you have effectively reset the key.
nraj
Participant
Posts: 15
Joined: Tue Feb 22, 2005 9:22 am

Post by nraj »

Hi ArndW

Yeah i'm Expecting DataStage generated keys using the KeyMgtGetNextValue only.

Plz let us know the Sql which does the reset of SRkey.
ArndW
Participant
Posts: 16318
Joined: Tue Nov 16, 2004 9:08 am
Location: Germany
Contact:

Post by ArndW »

nraj,

you can call "DSExecute('UV','DELETE SDKSequences {yourKey}',CommandOutput,ErrorCode)" which will remove the record and then the next time you use the sequence {yourKey} it will start at 0 again. If you plan on doing this often then it would be worth creating a short function such as KeyMgtResetValue that will do the job.

The SQL call is dependant upon the database you are using
elavenil
Premium Member
Premium Member
Posts: 467
Joined: Thu Jan 31, 2002 10:20 pm
Location: Singapore

Post by elavenil »

Hi ArndW,

Is it possible to set initial value to the sequence rather than deleting the sequence?. Am thinking of rerun process if this function used to generate surrogate key for a dimension.

Pls share your views.

Regards
Saravanan
ArndW
Participant
Posts: 16318
Joined: Tue Nov 16, 2004 9:08 am
Location: Germany
Contact:

Post by ArndW »

If you go into the manager you can look at the source code for KeyMgtResetValue. It is quite simple and straightforward to read the BASIC code and it should show you how you could make your own copy of this routine that will reset the value and/or restart the value at some other position. I would write a function with an extra parameter.
rasi
Participant
Posts: 464
Joined: Fri Oct 25, 2002 1:33 am
Location: Australia, Sydney

Post by rasi »

Hi Saravanan

Whenever you want to reset this then you need to update the value in universe.
Syntax:
UPDATE SDKSequences USING DICT VOC SET F1 = 'New_Value' WHERE @ID = 'Sequence_Name';

You can use this in the before/after subroutine or create a function of your own.

Thanks
Regards
Siva

Listening to the Learned

"The most precious wealth is the wealth acquired by the ear Indeed, of all wealth that wealth is the crown." - Thirukural By Thiruvalluvar
elavenil
Premium Member
Premium Member
Posts: 467
Joined: Thu Jan 31, 2002 10:20 pm
Location: Singapore

Post by elavenil »

Thanks Siva.

It is working fine.

Regards
Saravanan
Post Reply