StageVariable

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
pandu80
Participant
Posts: 50
Joined: Fri Apr 08, 2005 5:56 pm

StageVariable

Post by pandu80 »

Hi,
Iam new to DS.
Iam defining a StageVariabe svLocId like

If x='hyd' then 1234
Else If x='delhi' then 3456
Else If x='Bangalore' then
(If (zipcd>2456 and zipcd<2500) Then = 8976 else 8977)
Else If x='Bombay' then
(If (zipcd>2456 and zipcd<2500) Then = 8976 else 8977)
Else 9999

Can i define in this way or not.
If i ask a stupid question please bear me.

TIA
chulett
Charter Member
Charter Member
Posts: 43085
Joined: Tue Nov 12, 2002 4:34 pm
Location: Denver, CO

Post by chulett »

Welcome Aboard! :D

I think your expression is fine... syntactically, except for the extra equal signs:

Code: Select all

If x='hyd' then 1234 
Else If x='delhi' then 3456 
Else If x='Bangalore' then 
(If (zipcd>2456 and zipcd<2500) Then 8976 else 8977) 
Else If x='Bombay' then 
(If (zipcd>2456 and zipcd<2500) Then 8976 else 8977) 
Else 9999
Or, to save a little code:

Code: Select all

If x='hyd' then 1234 
Else If x='delhi' then 3456 
Else If x='Bangalore' or x='Bombay' then 
(If (zipcd>2456 and zipcd<2500) Then 8976 else 8977) 
Else 9999
Best way to check the output is to write a quick routine via the Manager with that exact syntax. Pass in two arguments and either rename them to match your names or change all references to 'x' and 'zipcd' in your code to 'Arg1' and 'Arg2'. Then you'll need to assign the output to the variable 'Ans' which is required. So the routine code would look like:

Code: Select all

If Arg1='hyd' then Ans=1234 
Else If Arg1='delhi' then Ans=3456 
Else If Arg1='Bangalore' or Arg1='Bombay' then 
(If (Arg2>2456 and Arg2<2500) Then Ans=8976 else Ans=8977) 
Else Ans=9999
Save, Compile and then you can use the 'Test' button to run various values of Arg1 throught it to ensure you get the right Answer back each time. :wink:
-craig

"You can never have too many knives" -- Logan Nine Fingers
pandu80
Participant
Posts: 50
Joined: Fri Apr 08, 2005 5:56 pm

Post by pandu80 »

Thanks Craig
chulett wrote:Welcome Aboard! :D

I think your expression is fine... syntactically, except for the extra equal signs:

Code: Select all

If x='hyd' then 1234 
Else If x='delhi' then 3456 
Else If x='Bangalore' then 
(If (zipcd>2456 and zipcd<2500) Then 8976 else 8977) 
Else If x='Bombay' then 
(If (zipcd>2456 and zipcd<2500) Then 8976 else 8977) 
Else 9999
Or, to save a little code:

Code: Select all

If x='hyd' then 1234 
Else If x='delhi' then 3456 
Else If x='Bangalore' or x='Bombay' then 
(If (zipcd>2456 and zipcd<2500) Then 8976 else 8977) 
Else 9999
Best way to check the output is to write a quick routine via the Manager with that exact syntax. Pass in two arguments and either rename them to match your names or change all references to 'x' and 'zipcd' in your code to 'Arg1' and 'Arg2'. Then you'll need to assign the output to the variable 'Ans' which is required. So the routine code would look like:

Code: Select all

If Arg1='hyd' then Ans=1234 
Else If Arg1='delhi' then Ans=3456 
Else If Arg1='Bangalore' or Arg1='Bombay' then 
(If (Arg2>2456 and Arg2<2500) Then Ans=8976 else Ans=8977) 
Else Ans=9999
Save, Compile and then you can use the 'Test' button to run various values of Arg1 throught it to ensure you get the right Answer back each time. :wink:
Post Reply