OR Operator

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
sid19
Participant
Posts: 64
Joined: Mon Jun 18, 2007 12:17 am
Location: kolkata

OR Operator

Post by sid19 »

Hi,

In transformer stage we have one input and one outputlink. For one of output field we have following derivation

If LkpSYSTEMIC.ACCOUNT = '119FCE' or '119FSA' Then 1 Else 2

When we pass LkpSYSTEMIC.ACCOUNT = '119FCH' then from above expression it gives output value 1

When we changed the expression as follows
If LkpSYSTEMIC.ACCOUNT = '119FCE' or LkpSYSTEMIC.ACCOUNT = '119FSA' Then 1 Else 2

In this case it gives value 2.

What is wrong in the first expression which gives value as 1?

Thanks,
Sid
ray.wurlod
Participant
Posts: 54607
Joined: Wed Oct 23, 2002 10:52 pm
Location: Sydney, Australia
Contact:

Post by ray.wurlod »

The rule here is, in a Boolean context: 0 or "" is False, anything else is True.

'119FSA' is therefore True

LkpSYSTEMIC.ACCOUNT = '119FCE' or '119FSA' is parsed as: (LkpSYSTEMIC.ACCOUNT = '119FCE') or ('119FSA')
(Logical operators have the lowest precedence.)

(LkpSYSTEMIC.ACCOUNT = '119FCE') or ('119FSA') is True because ('119FSA') is always True, so that your If..Then..Else expression will always return 1.

Your second formulation is the correct way to perform the test that you intended.

LkpSYSTEMIC.ACCOUNT = '119FCE' or LkpSYSTEMIC.ACCOUNT = '119FSA' is parsed as (LkpSYSTEMIC.ACCOUNT = '119FCE') or (LkpSYSTEMIC.ACCOUNT = '119FSA')
IBM Software Services Group
Any contribution to this forum is my own opinion and does not necessarily reflect any position that IBM may hold.
Post Reply