How to generate only odd values/numbers in surrogate key gen

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
bond88
Participant
Posts: 109
Joined: Mon Oct 15, 2012 10:05 am
Location: USA

How to generate only odd values/numbers in surrogate key gen

Post by bond88 »

Hi,
Could anyone please suggest me how to generate only odd numbers as (1,3,5,....) surrogate keys ?

Thank you,
Bhanu
asorrell
Posts: 1707
Joined: Fri Apr 04, 2003 2:00 pm
Location: Colleyville, Texas

Post by asorrell »

Run them through a constraint where numbers evenly divisible by two aren't passed on.

Per numerous other posts - this does not guarantee that the generated numbers will hit every odd number in sequence (there will be gaps), just that only odd numbers will get through.
Andy Sorrell
Certified DataStage Consultant
IBM Analytics Champion 2009 - 2020
bart12872
Participant
Posts: 82
Joined: Fri Jan 19, 2007 5:38 pm

Post by bart12872 »

in a transformer, use
(@PARTITIONNUM*2+1) + ((@NUMPARTITIONS*2)*(@INROWNUM-1))
Post Reply