Transformer , IF condition

A forum for discussing DataStage<sup>®</sup> basics. If you're not sure where your question goes, start here.

Moderators: chulett, rschirm, roy

Post Reply
karthi_gana
Premium Member
Premium Member
Posts: 729
Joined: Tue Apr 28, 2009 10:49 pm

Transformer , IF condition

Post by karthi_gana »

Hi,

I have a file which has two field.

report_code integer 10
report_name varchar(255)
field_value varchar(255)

sequential file


Transformer

will trasfer it to a sequential file based on some logic.

if report_code = 59 then i have to store the value in date column. Because it has datetime value.

if report_code = 60 then i have to store the value in rank column.

So i include like

if (DS4Link.report_code <> 59 or DS4Link.report_code <> 60 )then DS6Link.field_value else 0

this is for field_value


if (DS4Link.report_code = 59 then DS6Link.field_value else 0

this for date column

if (DS4Link.report_code = 60 then DS6Link.field_value else 0

this is for rank column

But the value are not going as expected.






sequential file:

report_code integer 10
report_name varchar 255
field_value numeric 18,8
date timestamp 23 3
rank varchar(5)
Karthik
chulett
Charter Member
Charter Member
Posts: 43085
Joined: Tue Nov 12, 2002 4:34 pm
Location: Denver, CO

Post by chulett »

Faulty expression... your 'or' should be an 'and', otherwise 59 <> 60 and 60 <> 59 so everything goes down it.
-craig

"You can never have too many knives" -- Logan Nine Fingers
pratapsriram
Premium Member
Premium Member
Posts: 41
Joined: Tue Jan 24, 2006 3:43 pm
Location: United States
Contact:

Post by pratapsriram »

The nested If Then Else syntax should be If [condition] Then [output] Else If [condition] Then [output] Else If [condition] Then [output] Else [output].
In your case you don't need a nested condition, I think. You can use two transformers and a funnel stage to acheive it. In your first transformer use a constraint for DSLink.Report_code=59, in the second use DSLink.Report_code=60. Funnel the outputs into a sequential file or a database target.
Kryt0n
Participant
Posts: 584
Joined: Wed Jun 22, 2005 7:28 pm

Post by Kryt0n »

Stick with what Craig said...

plus, why have you got DSLink4 in your comparison and then referencing DSLink6 in your output, are you doing a join?
ray.wurlod
Participant
Posts: 54607
Joined: Wed Oct 23, 2002 10:52 pm
Location: Sydney, Australia
Contact:

Re: Transformer , IF condition

Post by ray.wurlod »

karthi_gana wrote:I have a file which has two field.

report_code integer 10
report_name varchar(255)
field_value varchar(255)
Attention to detail is very important in an ETL developer.
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