Page 1 of 1

if then else

Posted: Tue Jun 13, 2006 4:15 am
by balajisr
In the construct "if then else" used in the transfomer it is mandatory to give some values for else clause.

E.g If Color='Green' then 1 Else 0

Is it possible to make "Else" portion of "If then Else" a no-op code? i.e I do not want Else portion of code to be executed at all.

Posted: Tue Jun 13, 2006 4:49 am
by ArndW
In the BASIC language you can do this, but when using the construct in DataStage jobs the result of the IF-THEN-ELSE is assigned to a variable, i.e. it is the right side of an "=" statement. Because of this an IF clause must assign a value to both outcomes of the condition.

Posted: Tue Jun 13, 2006 3:08 pm
by ray.wurlod
The If..Then..Else construct here is a conditional expression (not a statement) and therefore must return a value irrespective of the result of the test expression. The concept of "no operation" is irrelevant.

You will notice in the Then and Else parts there are value-generating expressions, not executable statements.

In routines you can use conditional expressions as rvalues (on the right hand side of an assignment statement for example) and the same rules apply there.

Posted: Tue Jun 13, 2006 11:48 pm
by balajisr
Thanks ArndW and Ray.