Doubt in 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
somu_june
Premium Member
Premium Member
Posts: 439
Joined: Wed Sep 14, 2005 9:28 am
Location: 36p,reading road

Doubt in Surrogate key

Post by somu_june »

Hi,

Iam generating a keys using surrogate key . My actual requirement is

Ex: If Iam running the same job twice then I have to generate keys for first run as 1......70 . Its working fine. But If I want to run the job for second time with different file I want to generate key starting with 71.....so on. Is there any option like that in surrogate key stage.



Thanks,
somaraju.
somaraju
meena
Participant
Posts: 430
Joined: Tue Sep 13, 2005 12:17 pm

Re: Doubt in Surrogate key

Post by meena »

Hi Somaraju,
I am new to datastage. But I can give you a idea how to do it, well lets try it. It may work. I want to know what are the stages you are using in the DS job design. If you are using a Oracle stage in your design then you can use "sequencename(columnname).NextVal" and assign 71 in Insert.

Meena
somu_june wrote:Hi,

Iam generating a keys using surrogate key . My actual requirement is

Ex: If Iam running the same job twice then I have to generate keys for first run as 1......70 . Its working fine. But If I want to run the job for second time with different file I want to generate key starting with 71.....so on. Is there any option like that in surrogate key stage.



Thanks,
somaraju.
somu_june
Premium Member
Premium Member
Posts: 439
Joined: Wed Sep 14, 2005 9:28 am
Location: 36p,reading road

Re: Doubt in Surrogate key

Post by somu_june »

Hi meena,

Iam not using any oracle stages. Actually Iam generating seq of numbers and writing to a file. Iam getting a date from flat file and Iam grouping by date and generating a surrogate key for that group and loading that number like DMT1,DMT2,........DMt79 to seq file.



Thanks,
Somaraju
somaraju
aramachandra
Participant
Posts: 55
Joined: Tue Sep 20, 2005 10:58 am

Post by aramachandra »

Surrogate key generator is not persistant in px jobs.

It expects you to remember your last generated number.

YOu could write last sequence into a seqencial file , so in your case you will write 70 to a sequential file.

On the next run you will read it from the sequential file and pass it as a paremeter to your job which has the surrogate key and use that as a starting seed.

You will have to use sequences to pass parameters, but the above is one way.

I am sure there are a few other ways as well

arvind
somu_june
Premium Member
Premium Member
Posts: 439
Joined: Wed Sep 14, 2005 9:28 am
Location: 36p,reading road

Post by somu_june »

Hi Arvind,


Can you explain me how to make a parameter the value and how to pass that parameter when Iam running the same job again.

Can any one tell me is there any other way than this.



Thanks,
Somaraju
somaraju
kumar_s
Charter Member
Charter Member
Posts: 5245
Joined: Thu Jun 16, 2005 11:00 pm

Post by kumar_s »

Hi,
During each run, find the max of the key which got generated. As explained, write the that value to another file with any identifier. Using the edentifier pick up the lates one and pass as a paramter to a job. You can use Batch code to perform this. Or you can also use execute command activity to read (cat) the file (from the sequence) ans pass as paramter to the next statage.
In surrogate Key Generator, a option called 'Start Value' is available. It can be parameterized. Pass the parameter with thevalue '70' in your case to the start value.

-Kumar
Post Reply