if then else

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
scorpion
Participant
Posts: 144
Joined: Thu May 12, 2005 4:19 am

if then else

Post by scorpion »

Hi,

I am looking for simple IF-THEN-ELSE Logic for my below reqrment...

Could any one help me on this please..

if column1 = 'DSX' Then 'Datastage' Else 'Dstage' Else 'Ascential'

how do i keep im if then else in transformer?

Thanks all!
Thanx&Regards
scorpion
scorpion
Participant
Posts: 144
Joined: Thu May 12, 2005 4:19 am

Post by scorpion »

HiAll ,

In my requirement i need to use 2 else statements..

if the value of the ColumnA = 'dsx' then populate TARCOL1,if this is blank THEN populate TARCOL2.if this column also blank then populate TARCOL3.

any Advises please?
Thanx&Regards
scorpion
Abu@0403
Participant
Posts: 32
Joined: Wed Aug 08, 2007 11:21 pm

Re: if then else

Post by Abu@0403 »

Your requirement is unclear.

Anyhow I will give you a sample logic. Check if this is fine.

If Col1 = "DSX" Then "DataStage"
Else If Col1 = "DX" Then "Dstage"
Else "Ascential"

If you want exact solution then give the condition to get "Dstage" in your requirement.
----------------
Abu
scorpion
Participant
Posts: 144
Joined: Thu May 12, 2005 4:19 am

Post by scorpion »

Hi Abu,

Thanks for the reply,below is my exact reqrmnt:

if the value of the ColumnA = 'dsx' then populate TARCOL1,if this is blank THEN populate TARCOL2.if this column also blank then populate TARCOL3.

Could you please advise on this?

Sorry for the confusion..
Thanx&Regards
scorpion
Abu@0403
Participant
Posts: 32
Joined: Wed Aug 08, 2007 11:21 pm

Post by Abu@0403 »

If ColumnA = 'dsx' Then
If Len(Trim(TARCOL1))=0 Then
If Len(Trim(TARCOL2))=0 Then TARCOL3
Else TARCOL2
Else TARCOL1
Else
<Condition if ColumnA<>"DSX">

I havent used this function like len(Trim) rather I have routine being used. So check if this is correct.
----------------
Abu
scorpion
Participant
Posts: 144
Joined: Thu May 12, 2005 4:19 am

Post by scorpion »

Hi ,

values are in my columns are varchar type.So some are the values are nulls.

rqrmnt:

if the value of the ColumnA = 'dsx' then populate TARCOL1,if this value is null THEN populate TARCOL2.if this column values is also null then populate TARCOL3.
Thanx&Regards
scorpion
scorpion
Participant
Posts: 144
Joined: Thu May 12, 2005 4:19 am

Post by scorpion »

can any one helpme on this please?
Thanx&Regards
scorpion
chulett
Charter Member
Charter Member
Posts: 43085
Joined: Tue Nov 12, 2002 4:34 pm
Location: Denver, CO

Post by chulett »

:? Still unclear. If you spell out what needs to happen in writing under all conditions, it should be pretty easy to do whatever it is you need to do.


If ColumnA = 'dsx' then populate TARCOL1 with what?

If ColumnA is null, then populate TARCOL2 & TARCOL3 with what?
-craig

"You can never have too many knives" -- Logan Nine Fingers
scorpion
Participant
Posts: 144
Joined: Thu May 12, 2005 4:19 am

Post by scorpion »

Hi Chullet,

ColumnA,TARCOL1,TARCOL2 & TARCOL3 are my source columns:

And i have to populate one my target column(TARGETCOL) like below:

if the value of the ColumnA = 'dsx' then map TARCOL1,Else map TARCOL2.if this column values is also null then populate TARCOL3.
Thanx&Regards
scorpion
chulett
Charter Member
Charter Member
Posts: 43085
Joined: Tue Nov 12, 2002 4:34 pm
Location: Denver, CO

Post by chulett »

Let's try again. This makes no sense as you've said it is a source column:

"if this column values is also null then populate TARCOL3."

Stop saying the same thing over and over and rephrase it so it makes more sense. Which column is 'this column'? All I can gather right now is if ColumnA = 'dsx' then you need to populate TARGETCOL with TARCOL1 else populate TARGETCOL with TARCOL2. So far, that's just one simple perfectly normal if-then-else statement.

Other than that... :?
-craig

"You can never have too many knives" -- Logan Nine Fingers
scorpion
Participant
Posts: 144
Joined: Thu May 12, 2005 4:19 am

Post by scorpion »

Thanks for your reply chullet,

Othere than that

if TARCOL2(second source column) also null then populate TARGETCOL with TARCOL3(3rd source column)..

so to populate TARGETCOL:

if the value of the ColumnA = 'dsx' then map TARCOL1,
Else map TARCOL2.if this column value(TARCOL2) is null then mapTARCOL3.

here i need 2 ELSE conditions.
Thanx&Regards
scorpion
chulett
Charter Member
Charter Member
Posts: 43085
Joined: Tue Nov 12, 2002 4:34 pm
Location: Denver, CO

Post by chulett »

Ok, that makes more sense. You need two if-then-else expressions, not just "two else conditions". Psuedo-code for the TARGETCOL derivation:

Code: Select all

If ColumnA = 'dsx' Then TARCOL1 Else If IsNull(TARCOL2) Then TARCOL3 Else TARCOL2
You'll need to add link names and make it all PX-like (not sure about IsNull in PX) but you should get the idea now.
-craig

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