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
krisp321
Participant
Posts: 39
Joined: Thu Mar 04, 2010 12:39 am

Surrogate key generator

Post by krisp321 »

Hi

my source data is like for example

KeyColNm Surrogatekey
------------
A .............10
A .............20
A .............30
A .............40
B .............10
B .............20
B .............30
C .............10
C .............20
C .............30
C .............40
C ............. 50

Means, like my requirement is when data value changes in key column, then the surrogate value should start from initial values and should increment 10 when the value is repeating.

Any suggestions please

Thanks
thompsonp
Premium Member
Premium Member
Posts: 205
Joined: Tue Mar 01, 2005 8:41 am

Post by thompsonp »

Sort the data and choose to generate a key change column, then in a transformer derive the key values starting at 10 (when keyChange is 1) and incrementing by 10 (when keyChange = 0)
ulab
Participant
Posts: 56
Joined: Mon Mar 16, 2009 4:58 am
Location: bangalore
Contact:

sarogate Key

Post by ulab »

Yes that is Right, and if you want to generate with a increment of 1 then use the following as a stage varible in transformar "0 + @INROWNUM +(mod(@PARTITIONNUM,@NUMPARTITIONS)) + ((@INROWNUM-1) * (@NUMPARTITIONS-1))"
Ulab----------------------------------------------------
help, it helps you today or Tomorrow
vivekgadwal
Premium Member
Premium Member
Posts: 457
Joined: Tue Sep 25, 2007 4:05 pm

Re: sarogate Key

Post by vivekgadwal »

ulab wrote:Yes that is Right, and if you want to generate with a increment of 1 then use the following as a stage varible in transformar "0 + @INROWNUM +(mod(@PARTITIONNUM,@NUMPARTITIONS)) + ((@INROWNUM-1) * (@NUMPARTITIONS-1))"
This derivation of yours works with only round-robin partitioning, correct?
Vivek Gadwal

Experience is what you get when you didn't get what you wanted
ray.wurlod
Participant
Posts: 54607
Joined: Wed Oct 23, 2002 10:52 pm
Location: Sydney, Australia
Contact:

Post by ray.wurlod »

Not correct.
IBM Software Services Group
Any contribution to this forum is my own opinion and does not necessarily reflect any position that IBM may hold.
boringbaby
Participant
Posts: 3
Joined: Wed Jun 11, 2008 8:08 am

Post by boringbaby »

I agree with thompsonp .
Doesn't it work?
Hello,world!
Post Reply