If..Else if...else

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
gateleys
Premium Member
Premium Member
Posts: 992
Joined: Mon Aug 08, 2005 5:08 pm
Location: USA

If..Else if...else

Post by gateleys »

I have 2 stage variables sv1 and sv2, each of which maintain the previous IDs, say empID and storeID, respectively. I need to use a logic such as-

If (sv1=True And sv2=True) then 1 Else If (sv1=True And sv2<> True) then 0 Else 1. The code I used is-

Code: Select all

If (sv1 AND sv2) Then 1 Else If (sv1 AND NOT(sv2)) Then 0 Else 1
Although there are records which satisfy each of the above cases, it always takes the Else path...and give me a 1. Even when I exclude either the first or second clause from the above code, it still gives me the Else condition to return 1. Please tell me where I have gone wrong.
gateleys
Premium Member
Premium Member
Posts: 992
Joined: Mon Aug 08, 2005 5:08 pm
Location: USA

Post by gateleys »

How would you write a routine for the same?
tcj
Premium Member
Premium Member
Posts: 98
Joined: Tue Sep 07, 2004 6:57 pm
Location: QLD, Australia
Contact:

Post by tcj »

Code: Select all

If (Not(IsNull((sv1)) AND Not(IsNull(sv2))) Then 1 Else If (Not(IsNull(sv1)) AND IsNull(sv2)) Then 0 Else 1
I assume that if the previous IDs aren't there then the Stage variable is null.

What is the derivation for the stage variables?
gateleys
Premium Member
Premium Member
Posts: 992
Joined: Mon Aug 08, 2005 5:08 pm
Location: USA

Post by gateleys »

I am using the necessary function(RowProcPreviousCompare) for comparison. My understanding is that the previous value for ID will be there after the first row is processed. Did I miss anything?
tcj
Premium Member
Premium Member
Posts: 98
Joined: Tue Sep 07, 2004 6:57 pm
Location: QLD, Australia
Contact:

Post by tcj »

Yes it will be.

Are you sure that both the records are the same as the previous records at the same time in your data?

Your code should work based on the output of the Rowcompare routine.
kduke
Charter Member
Charter Member
Posts: 5227
Joined: Thu May 29, 2003 9:47 am
Location: Dallas, TX
Contact:

Post by kduke »

I prefer making each if then a complete statement:

Code: Select all

If (sv1 AND sv2) Then 1 Else "" : (If (sv1 AND NOT(sv2)) Then 0 Else 1)
Mamu Kim
Post Reply