Multiple SNO's and Flagging them

Post questions here relative to DataStage Server Edition for such areas as Server job design, DS Basic, Routines, Job Sequences, etc.

Moderators: chulett, rschirm, roy

Post Reply
vsi
Premium Member
Premium Member
Posts: 507
Joined: Wed Mar 15, 2006 1:44 pm

Multiple SNO's and Flagging them

Post by vsi »

Hi
i have a scenario like this

S.NO Code Flag1 Flag2 Flag3
123 so12 Y N N
123 So13 Y Y N


When Code matches then Flag 1,it is Marked as 'Y' and again when the same SNO comes again with diff. code then mark flag2 as 'Y' along with Flag1(we should not change the old one) when it does not match with FLAG1 or Flag2 then Flag3 should be 'Y'
ArndW
Participant
Posts: 16318
Joined: Tue Nov 16, 2004 9:08 am
Location: Germany
Contact:

Post by ArndW »

Sort your incoming data according to S.NO and Code, then use stage variables to store the values from the previous row so that you can use your logic.
DSguru2B
Charter Member
Charter Member
Posts: 6854
Joined: Wed Feb 09, 2005 3:44 pm
Location: Houston, TX

Post by DSguru2B »

Sort your data by S.No
Use stage variables to check the current with previous.
Use if then else statements to set the values of the flags.
Creativity is allowing yourself to make mistakes. Art is knowing which ones to keep.
vsi
Premium Member
Premium Member
Posts: 507
Joined: Wed Mar 15, 2006 1:44 pm

Hi

Post by vsi »

Hi,
I am New so Pls. give me more Info in Using Stage Variables,How to store SNO and compare with the new one


Thanks a lot
DSguru2B
Charter Member
Charter Member
Posts: 6854
Joined: Wed Feb 09, 2005 3:44 pm
Location: Houston, TX

Post by DSguru2B »

This has been covered a lot here. Use the search facility.
For a start check out these two posts
POST1
POST 2
Creativity is allowing yourself to make mistakes. Art is knowing which ones to keep.
rwierdsm
Premium Member
Premium Member
Posts: 209
Joined: Fri Jan 09, 2004 1:14 pm
Location: Toronto, Canada
Contact:

Re: Hi

Post by rwierdsm »

vsi wrote:Hi,
I am New so Pls. give me more Info in Using Stage Variables,How to store SNO and compare with the new one


Thanks a lot
3 Stage variables:

ThisRowValue => S.NO
CompareToLastValue => If ThisRowValue = LastRowValue then 1 else 0
LastRowValue => ThisRowValue

Since the stage variables get evaluated in order, the value from teh last row is maintained until the 3rd stage variable is reassigned. THIS MEANS THAT THE ORDER OF DECLARATION IS IMPORTANT.

(I had to find that out once the hard way :-))

Extend it for your two values.

Rob W.
Rob Wierdsma
Toronto, Canada
bartonbishop.com
Post Reply