Page 1 of 1

Transformer , IF condition

Posted: Thu Jan 28, 2010 6:52 am
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)

Posted: Thu Jan 28, 2010 8:34 am
by chulett
Faulty expression... your 'or' should be an 'and', otherwise 59 <> 60 and 60 <> 59 so everything goes down it.

Posted: Thu Jan 28, 2010 9:35 am
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.

Posted: Thu Jan 28, 2010 2:06 pm
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?

Re: Transformer , IF condition

Posted: Thu Jan 28, 2010 3:21 pm
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.