Page 1 of 1

Surrogate Key generator

Posted: Thu Apr 05, 2007 4:27 pm
by UPS
Any advise on how to generate surrogate keys within datastage and reuse them within and in the next batch process. Currently, we utilize oracle's sequence option to manage the surrogate keys in our database. We are planning to leverage the Datastage Key generator option to minimize calls to the database during the batch processing. Any suggestions is appreciated.

Posted: Thu Apr 05, 2007 4:44 pm
by us1aslam1us
Either you can do that by using @INROWNUM and @OUTROWNUM variables in tranformer or if you are on PX version you will have 'Surrogate Key Generator stage' which can do that. If you need more details do a search on exact term.

Posted: Thu Apr 05, 2007 9:42 pm
by swades
THIS will help you

Posted: Thu Apr 05, 2007 10:01 pm
by chulett
:? Link isn't working for me. And it's more than just the missing 'www.' on dsxchange.com - the topic doesn't seem to exist or we need a different syntax. Can you try that again, please?

Posted: Thu Apr 05, 2007 10:03 pm
by chulett

Posted: Fri Apr 06, 2007 3:00 pm
by ccatania
I had a similar requirement, where the sur-key was incremented in one process and had to used in another. I wrote the Sur-key value to a work table, then in a Server job did a select max on that value, passed it to a variable and executed the next job through the server transform. The job executed from the server process, would increment the sur-key value and write it to the work table. I sure there are other ways to do this, but this worked for me. I hope this helps.

Surrogate Key generator

Posted: Sun Apr 08, 2007 12:47 am
by syed_subhaan
I understand that your req is to generate surrogate keys for the database..

The best way i think you can do it (alternative to sequence of database) is to design a shared container so that it will generate a surrogate key for the previous high value by using a transformer or surrogate key generator..
And plugin the shared container in your job wherever applicable..

Write the max(surrogate key) to a file.
read the vlaue for the file
and increment the value by 1 for each input record read...
You can use transformer stage for this..

Regards,
Subhani

Posted: Sun Apr 08, 2007 4:16 am
by ray.wurlod
You don't need anything intermediate. You can select the value directly into the reference link into a Lookup stage. Make sure that partitioning is Entire. Then add this (constant) value to the zero-based sequence generated in the Surrogate Key Generator or Column Generator stage, where it should have a beginning value of the partition number and an increment of the partition count.