Possibility to set value for a StageVariable in another SV?

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
vnspn
Participant
Posts: 165
Joined: Mon Feb 12, 2007 11:42 am

Possibility to set value for a StageVariable in another SV?

Post by vnspn »

Hi,

We are working on verion 7.1. I have a question like - Is it not possible to set a value for a Stage Variable in another Stage Variable ?

Ok, here is my scenario. I have 2 Stage Variables. One has an 'If' condition in it and another has a 'counter' expression in it. So, I would need to increment the counter for each record. But when a particular condition occurs, I would need to reset the value of counter back to '0'. Let me show using the real case how it looks -

Stage Variable ----------> Expression
--------------------------------------------
sv1 -----------------------> If <condition> Then <expression1> Else sv2=0
sv2 -----------------------> sv2+1

This is kind of logic that I'm using. The expression after the 'Else' clause does not seem to work. Even when the given condition is untrue, the sv2 is not set to '0'. It keeps on incrementing by '1' for every record.

Is this a kind of fuctionality that is not supported by DS? Is is not possible to assign a value to a Stage Variable from another Stage Variable?

Thanks.
kcbland
Participant
Posts: 5208
Joined: Wed Jan 15, 2003 8:56 am
Location: Lutz, FL
Contact:

Post by kcbland »

No. Stage variables are assignment operations.

Code: Select all

sv = (if <condition> then <result1> else <result2>)
Simply just rewrite your stage variables to work accordingly.

Code: Select all

sv0 = <condition>
sv1 = (if sv0 then <expression1> else sv1)
sv2 = (if sv0 then sv2+1 else 1)
Kenneth Bland

Rank: Sempai
Belt: First degree black
Fight name: Captain Hook
Signature knockout: right upper cut followed by left hook
Signature submission: Crucifix combined with leg triangle
us1aslam1us
Charter Member
Charter Member
Posts: 822
Joined: Sat Sep 17, 2005 5:25 pm
Location: USA

Post by us1aslam1us »

The way you are assigning the Stage variables is wrong. Seperate your Condition into a seperate Stage variable (sv0) then define

Code: Select all

sv1 = (if sv0 then expr else sv1)
sv2= (if sv0 then sv2+1 else 0)
IHTH
I haven't failed, I've found 10,000 ways that don't work.
Thomas Alva Edison(1847-1931)
vnspn
Participant
Posts: 165
Joined: Mon Feb 12, 2007 11:42 am

Post by vnspn »

Thanks a lot Ken and us1aslam1us.

I would re-write my logic, the way Stage Variables work.

Thank you.
Post Reply