I have to use "in" condition within "if"

Post questions here relative to DataStage Enterprise/PX Edition for such areas as Parallel job design, Parallel datasets, BuildOps, Wrappers, etc.

Moderators: chulett, rschirm, roy

Post Reply
deesh
Participant
Posts: 193
Joined: Mon Oct 08, 2007 2:57 am

I have to use "in" condition within "if"

Post by deesh »

Hi,
Can any one help in this case,

if OKCUA4='' and OKCUA3 in (counties) then OKCUA2
else if OKCUA4='' and OKCUA3 not in (counties) then OKCUA3
else if OKCUA4 in (counties) then OKCUA3
else OKCUA4
shalini11
Participant
Posts: 74
Joined: Thu Jan 22, 2009 3:00 am

Post by shalini11 »

if OKCUA4='' and (OKCUA3=counties1 or OKCUA3=counties2...) then OKCUA2
else if OKCUA4='' and (OKCUA3<>counties1 or OKCUA3<>counties1 ...)then OKCUA3
else if (OKCUA4=counties1 or OKCUA4=counties2...)then OKCUA3
else OKCUA4
Mike
Premium Member
Premium Member
Posts: 1021
Joined: Sun Mar 03, 2002 6:01 pm
Location: Tampa, FL

Post by Mike »

If you have a manageable number of counties, then you can use the approach suggested by shalini11. If you have hundreds or thousands of counties to check, then you'd want to use the lookup stage to implement your "in" and "not in" logic.

Mike
DSguru2B
Charter Member
Charter Member
Posts: 6854
Joined: Wed Feb 09, 2005 3:44 pm
Location: Houston, TX

Post by DSguru2B »

Or maybe the index function.
Creativity is allowing yourself to make mistakes. Art is knowing which ones to keep.
kandyshandy
Participant
Posts: 597
Joined: Fri Apr 29, 2005 6:19 am
Location: Singapore

Post by kandyshandy »

shalini11 wrote:if OKCUA4='' and (OKCUA3=counties1 or OKCUA3=counties2...) then OKCUA2
else if OKCUA4='' and (OKCUA3<>counties1 or OKCUA3<>counties1 ...)then OKCUA3
else if (OKCUA4=counties1 or OKCUA4=counties2...)then OKCUA3
else OKCUA4
It should be AND, not OR

if OKCUA4='' and (OKCUA3=counties1 or OKCUA3=counties2...) then OKCUA2
else if OKCUA4='' and (OKCUA3<>counties1 AND OKCUA3<>counties1 ...)then OKCUA3
else if (OKCUA4=counties1 or OKCUA4=counties2...)then OKCUA3
else OKCUA4

Or DSGuru's Index idea.
Kandy
_________________
Try and Try again…You will succeed atlast!!
Post Reply