Stage variables

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
samsuf2002
Premium Member
Premium Member
Posts: 397
Joined: Wed Apr 12, 2006 2:28 pm
Location: Tennesse

Stage variables

Post by samsuf2002 »

Hi All,

I have requirement where like

Code: Select all

KEY1,KEY2,COL3 
1,A,200
1,A,200
1,A,200
1,A,300
I need to check if value of COL3 changes for same KEY1 and KEY2 then I need to reject the entire existence of KEY1 KEY2 value like in the example since 1,A has different value of COL3 therefore 1,A should be excluded from further processing.

My attempt was creating 4 stage variables as
lastKEY1,lastKEY2,lastCOL3, EXCLUDE

Code: Select all

EXCLUDE as "if lastKEY1 = KEY1 and lastKEY2 = KEY2 and lastCOL3 = COL3 then 1 else 0
Now using EXCLUDE in constraint to filter out the KEYS where COL3 changes but even if there no change in COL3 the output has one less records for same KEY...looks like for the first record for any key its not finding the last values and assigning EXCLUDE as 0 ....

I am running the transformer in sequential mode.

Any suggestions will be appreciated.
hi sam here
ray.wurlod
Participant
Posts: 54607
Joined: Wed Oct 23, 2002 10:52 pm
Location: Sydney, Australia
Contact:

Post by ray.wurlod »

Why not use a Sort stage on all three columns and generate a Key Change column?
IBM Software Services Group
Any contribution to this forum is my own opinion and does not necessarily reflect any position that IBM may hold.
HariK
Participant
Posts: 68
Joined: Thu May 17, 2007 1:50 am

Post by HariK »

Use copy stage with two outputs
1--> remove duplicates on all three cols --> transformer with constraint & filter u menioned --> join stage
2 --> Join stage, join on key1, key2
Post Reply