simple if statement

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
mystuff
Premium Member
Premium Member
Posts: 200
Joined: Wed Apr 11, 2007 2:06 pm

simple if statement

Post by mystuff »

I have two functions defined as

NullChecking()

Code: Select all

if ((Trim(%arg1%, ' ', 'B') = '') Or (isnull(%arg1%))) Then 1 Else 0
Trimlt

Code: Select all

Trim(%arg1%, ' ', 'B')
When I use this in the transform as,

Code: Select all

if NullChecking(arg1) And Trimlt(arg2)=12345 Then
   'wrong'
Else
   'right'
I always get value as wrong.
I have checked individually the values of NullChecking(arg1) and Trimlt(arg2)=12345, and they are respectively 1 and 0. Still the result is 'wrong'. Any idea what could be going wrong. It looks so simple but strangely the result is always wrong.
us1aslam1us
Charter Member
Charter Member
Posts: 822
Joined: Sat Sep 17, 2005 5:25 pm
Location: USA

Post by us1aslam1us »

What values are you trying to pass in the Arguments? Also do you really mean both are functions :roll:
I haven't failed, I've found 10,000 ways that don't work.
Thomas Alva Edison(1847-1931)
ray.wurlod
Participant
Posts: 54607
Joined: Wed Oct 23, 2002 10:52 pm
Location: Sydney, Australia
Contact:

Post by ray.wurlod »

The two conditions either side of your AND connector can never simultaneously be true. NullChecking() is only true for "" or NULL.
IBM Software Services Group
Any contribution to this forum is my own opinion and does not necessarily reflect any position that IBM may hold.
mystuff
Premium Member
Premium Member
Posts: 200
Joined: Wed Apr 11, 2007 2:06 pm

Post by mystuff »

What values are you trying to pass in the Arguments? Also do you really mean both are functions
For the first condition, there is a value either Null or '' passed, I checked the result of first condition, it is giving 1

for secound condition, i am passing value other than 12345, I checked the result individually, it is giving 0

But when I And them, it is giving result value 1. Is this related to @TRUE or something like that.
The two conditions either side of your AND connector can never simultaneously be true. NullChecking() is only true for "" or NULL.
Ray the values passed to the two conditions are different.
rafik2k
Participant
Posts: 182
Joined: Wed Nov 23, 2005 1:36 am
Location: Sydney

Post by rafik2k »

it is giving result value 1. Is this related to @TRUE

Yes 1 means @true in the transformer
mystuff
Premium Member
Premium Member
Posts: 200
Joined: Wed Apr 11, 2007 2:06 pm

Post by mystuff »

I meant to say, is there something which I am not aware of,

Like arg1 & arg2 are both Decimal datatype (in sequential file), anything of that sort causing this problem. (changed them to numeric, bigint, still same result)

======================================

I am getting crazy, feels like there is nothing to debug.

Code: Select all

if svNullIdst Then 112 Else 
if (NullChecking(in.VCS_GRP_ID) And (TRIMLT(in.VCS_DIV_ID)=1222576)) Then 101 Else
if (NullChecking(in.VCS_GRP_ID) And (TRIMLT(in.VCS_DIV_ID)=1221747)) Then 102 Else
if (NullChecking(in.VCS_GRP_ID) And (TRIMLT(in.VCS_DIV_ID)=1221748)) Then 103 Else
if (NullChecking(in.VCS_GRP_ID) And (TRIMLT(in.VCS_DIV_ID)=1221751)) Then 104 Else
if (NullChecking(in.VCS_GRP_ID) And (TRIMLT(in.VCS_DIV_ID)=1221750)) Then 105 Else
if (NullChecking(in.VCS_GRP_ID) And (TRIMLT(in.VCS_DIV_ID)=1221761)) Then 106 Else
if (NullChecking(in.VCS_GRP_ID) And (TRIMLT(in.VCS_DIV_ID)=1221756)) Then 107 Else
if (NullChecking(in.VCS_GRP_ID) And (TRIMLT(in.VCS_DIV_ID)=1221755)) Then 108 Else
if (NullChecking(in.VCS_GRP_ID) And (TRIMLT(in.VCS_DIV_ID)=1221753)) Then 109 Else
if (NullChecking(in.VCS_GRP_ID) And (TRIMLT(in.VCS_DIV_ID)=1221771)) Then 110 Else
TRIMLT(in.VCS_GRP_ID)
The value of
in.VCS_DIV_ID is 1221748
and in.VCS_GRP_ID is either Null or ''

I get the result of this statment as 101 instead of 103..
rafik2k
Participant
Posts: 182
Joined: Wed Nov 23, 2005 1:36 am
Location: Sydney

Post by rafik2k »

Hope you have written routine like following

NullChecking:

Code: Select all

if ((Trim(Arg1, ' ', 'B') = '') Or (isnull(Arg1))) Then
 Ans = 1 
end Else
 Ans = 0 end
Trimlt:

Code: Select all

Ans=Trim(Arg1, ' ', 'B') 
What is svNullIdst?? is this stage variable? what is it's value??
if svNullIdst Then 112 Else

Remove this line and check it.
mystuff
Premium Member
Premium Member
Posts: 200
Joined: Wed Apr 11, 2007 2:06 pm

Post by mystuff »

Code: Select all

if ((Trim(Arg1, ' ', 'B') = '') Or (isnull(Arg1))) Then 
 Ans = 1 
end Else 
 Ans = 0 end
I had this in a trasfrom function NullChecking,

Shouldn't an if else construct be in transform function,
I have now changed the code to

Code: Select all

Trim(Arg1, ' ', 'B') = '' Or isnull(Arg1)
Post Reply