Page 1 of 1

Transformer derivation

Posted: Thu Sep 06, 2007 7:36 am
by scorpion
Hi All,

I need to write some derivation in my transformer like below:

if sourcecolumn1= 300 or 300% then populate 'xx'else blank.

my intension is, if the values are in source like 300 or 30045 or 30076 or 30088etc,whatever starts with 300 i need to populate as 'XX'.

SO below logic will work
IF sourcecolumn1='300%'then 'XX'else ''

?(will this look exactly for 300% or any thing starts with 300?)

can any one help me on this?

Posted: Thu Sep 06, 2007 7:43 am
by Maveric
Convert the values to string and get the first 3 characters using substring. Compare them using CompareNoCase(%string1%,%string2%) function in transformer.

Posted: Thu Sep 06, 2007 7:48 am
by scorpion
Hi Maveric Thanks for the reply,

It is very usefull forme,if you help me by giving exact derivation to me.

Posted: Thu Sep 06, 2007 7:53 am
by Maveric
You need to declare the sourcecolumn1 as varchar. Conversion from int to varchar will be implicit. so dont have to worry abt it.

IF CompareNoCase(sourcecolumn1[1,3],300) then 'XX 'else ''

Posted: Thu Sep 06, 2007 8:58 am
by scorpion
Hi,

Will Left function work in my scenario(means for integer type)?
Left((inputcolumn), 3)="700" or
Left((inputcolumn), 3)="701"

Posted: Thu Sep 06, 2007 9:01 am
by Maveric
You will have to tell me. Did u try it? What other options have you tried?

Posted: Thu Sep 06, 2007 4:17 pm
by ray.wurlod
Left() is a string function and [] (substring operator) is a string operator - you would need to convert the integer to a string to be able to use either Left() or [substring] notation.