Surrogate Key generator

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
srekant
Premium Member
Premium Member
Posts: 85
Joined: Wed Jan 19, 2005 6:52 am
Location: Detroit

Surrogate Key generator

Post by srekant »

I am using Suroogate Key generator.It is working fine for the current run, but, when i run the same jon the next day it is starting to generate keys starting fom 1.My requirement is it should start from where it left previous day.How can i achieve this.
Sree
T42
Participant
Posts: 499
Joined: Thu Nov 11, 2004 6:45 pm

Post by T42 »

The surrogate key generator always starts at 1, unless you provide it with an alternative value (using a parameter, perhaps), pull the latest value from somewhere (the database, perhaps), and doing the calculation in a transformer.

There are several solutions. The problem you had was that you think Surrogate Key Generator is something smart. It isn't. It counts based on partitions. It is really a glorified Column Generator with Part/PartCo.
bcarlson
Premium Member
Premium Member
Posts: 772
Joined: Fri Oct 01, 2004 3:06 pm
Location: Minnesota

Post by bcarlson »

We use Surrogate Keys a lot. You can use a variable (job parameter) to seed the generated id or always start with 1 and in the same job pull the max id + 1 of your target table (into which your new data will be loaded). Then in a transformer, as mentioned by T42, you can add the generated it to the seed value for each record.

By the way, to the world in general, can we lay off the sarcasm a bit?

Code: Select all

The problem you had was that you think Surrogate Key Generator is something smart. 
Post Reply