If Else problem

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
myukassign
Premium Member
Premium Member
Posts: 238
Joined: Fri Jul 25, 2008 8:55 am

If Else problem

Post by myukassign »

Sry to ask a simple doubt here, but i am in a desparate need for a solution.

I am writing a routine (Transform)

The folloing code is working fine

Routine 1
=======

Ans=""

Name="ABCD"

If (Name Match "0N") Then Ans= Name Else Ans=""

Return(Ans)


But the following is not working

Routine 2
=======

Ans=""

Name="ABCD"

If (Name Match "0N") Then
Ans= Name
Else
Ans=""

Return(Ans)


Wht is the problem here? I want to give multiple statements if the condition is true but it is not allowing me to do the second routine.

Can anyone help?
chulett
Charter Member
Charter Member
Posts: 43085
Joined: Tue Nov 12, 2002 4:34 pm
Location: Denver, CO

Post by chulett »

Confusing. I don't see any evidence that you are attempting 'multiple statements' in an if. Can you clarify? And your problem is - won't compile? Doesn't work as expected? :?
-craig

"You can never have too many knives" -- Logan Nine Fingers
ray.wurlod
Participant
Posts: 54607
Joined: Wed Oct 23, 2002 10:52 pm
Location: Sydney, Australia
Contact:

Post by ray.wurlod »

If "Then" or "Else" is the last word on its line then it opens a block of statements that must be terminated by an End statement.

Code: Select all

Ans="" 

Name="ABCD" 

If (Name Match "0N") Then 
   Ans= Name 
End
Else 
   Ans="" 
End

Return(Ans) 
or equivalently,

Code: Select all

Ans="" 

Name="ABCD" 

If (Name Match "0N") 
Then 
   Ans= Name 
End
Else 
   Ans="" 
End

Return(Ans) 
This is called "multi-line format" of the IF statement.
IBM Software Services Group
Any contribution to this forum is my own opinion and does not necessarily reflect any position that IBM may hold.
chulett
Charter Member
Charter Member
Posts: 43085
Joined: Tue Nov 12, 2002 4:34 pm
Location: Denver, CO

Post by chulett »

Ok, see that now. As noted, that's what happens when you move away from a 'one line' statement.
-craig

"You can never have too many knives" -- Logan Nine Fingers
myukassign
Premium Member
Premium Member
Posts: 238
Joined: Fri Jul 25, 2008 8:55 am

Post by myukassign »

Yeeee...

M done.....

Thanks a lot nd a lot and a lot
Post Reply