Logic required for If / then / else in tranformer

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
chulett
Charter Member
Charter Member
Posts: 43085
Joined: Tue Nov 12, 2002 4:34 pm
Location: Denver, CO

Post by chulett »

:?

That just needs to be one if-then-else, specifically the last one.
-craig

"You can never have too many knives" -- Logan Nine Fingers
naveenkumar.ssn
Participant
Posts: 36
Joined: Thu Dec 03, 2009 9:11 pm
Location: Malaysia

Re: Logic required for IF and else in tranformer

Post by naveenkumar.ssn »

Code: Select all

IF isnotNull(FROM_ACCT_NUM)
   then right(FROM_ACCT_NUM,2)
    else if 
          isnotNull(FROM_ACCT_NUM)
          then right(FROM_ACCT_NUM,2):'XXXXX' 
   else if 
          isnotNull(FROM_ACCT_NUM)
          then left((right(FROM_ACCT_NUM,2):'XXXXX'):FROM_ACCT_NUM,12)    ELSE
 FROM_ACCT_NUM
Naveen Kumar
Datastage Consultant
ray.wurlod
Participant
Posts: 54607
Joined: Wed Oct 23, 2002 10:52 pm
Location: Sydney, Australia
Contact:

Post by ray.wurlod »

Most of your ELSE expressions won't be evaluated because they include the same IF test as was processed in the THEN clause.

All you need is:

Code: Select all

If IsNotNull(InLink.ACCT_NUM) Then Left(InLink.ACCT_NUM,2) : "XXXXX" : Right(InLink.ACCT_NUM,12) Else InLink.ACCT_NUM
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 »

In other words... the last one. :wink:
-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 »

... except that the syntax given by naveenkumar.ssn (even in the last one) will not create the required result.
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 »

... was going to let them realize and attempt to correct that. Was also going to go back and edit my answer to say 'a variation of the last one' but decided to just let it stand.
-craig

"You can never have too many knives" -- Logan Nine Fingers
skp
Premium Member
Premium Member
Posts: 135
Joined: Wed Dec 26, 2007 1:56 am
Location: India

Post by skp »

Hi Hargun,

Please use below logic to get the desired output.

If IsNotNull(FROM_ACCT_NUM) Then Left(FROM_ACCT_NUM,2):'XXXXX':Right(FROM_ACCT_NUM,12) Else FROM_ACCT_NUM
qt_ky
Premium Member
Premium Member
Posts: 2895
Joined: Wed Aug 03, 2011 6:16 am
Location: USA

Post by qt_ky »

Ray has already given that answer above... :?
Choose a job you love, and you will never have to work a day in your life. - Confucius
chulett
Charter Member
Charter Member
Posts: 43085
Joined: Tue Nov 12, 2002 4:34 pm
Location: Denver, CO

Post by chulett »

Seems to be a bit of a serial repeater. :wink:
-craig

"You can never have too many knives" -- Logan Nine Fingers
Post Reply