How to assign previous value to stage variable?

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
taral
Participant
Posts: 16
Joined: Fri Mar 26, 2010 1:41 am

How to assign previous value to stage variable?

Post by taral »

I want to remove duplicate using stage variable.
For doing this I need to compare the current value of column with the previous value.
How do I maintain previous value in the stage variable?
kondeti
Premium Member
Premium Member
Posts: 67
Joined: Sat Mar 04, 2006 11:38 am

Post by kondeti »

Use this logic.

SCurrent: Link.input_key
SCompare: If SCurrent=SPrev then SCompare+1 else 1
SPrev:SCurrent (Default it to some empty value like "")

Thank you.
kondeti
Premium Member
Premium Member
Posts: 67
Joined: Sat Mar 04, 2006 11:38 am

Post by kondeti »

Sorry missed most important thing.

Before applying the above logic, Please sort the data on the key column then apply above logic. Thank you.
taral
Participant
Posts: 16
Joined: Fri Mar 26, 2010 1:41 am

Post by taral »

Thank You kondeti.

Do you mean
SCurrent value needs to be assigned to SPrev.
chulett
Charter Member
Charter Member
Posts: 43085
Joined: Tue Nov 12, 2002 4:34 pm
Location: Denver, CO

Post by chulett »

Yes. What is key to this is the order you declare the variables as they are evaluated top to bottom. That is what allows you to still know the "previous" value when the "current" value shows up.
-craig

"You can never have too many knives" -- Logan Nine Fingers
Post Reply