Page 1 of 1

trim function not working

Posted: Wed Apr 18, 2012 9:30 am
by sanoojk
Hi,

My job is fetching data from netezza database , doing transformations in transformer stage and writing to netezza daatbase.

In the transformer I am using the transformation len(trim(column1)) where column1 is having datatype char2 . I can see all the input value for column1 is '5' , but the transformer output shows 2 where as the expected value is 1 .

I tried with the transformation len(trimb(trimf(column1))) but the same result.

Please advise any way to trim the column1

Posted: Wed Apr 18, 2012 9:36 am
by priyadarshikunal
change the datatype to varchar or do this calculation in varchar stage varibale and see if it works.

Posted: Wed Apr 18, 2012 11:36 am
by chulett
Your char field will always have a length of 2, that's the way CHAR works. It won't have "5" in it, it will have "5 " in it and even if you trim them, any trailing spaces will be automagically added back in. Again, all part of the nature of a CHAR field.

Re: trim function not working

Posted: Wed Apr 18, 2012 2:38 pm
by rahcomp
Simply assign the value to a stage variable with type VARCHAR(2) and use it in the output column of type VARCHAR(2) with trim function

Re: trim function not working

Posted: Thu Apr 19, 2012 6:55 am
by priyadarshikunal
rahcomp wrote:Simply assign the value to a stage variable with type VARCHAR(1) or CHAR(1) and use it in the output column of type VARCHAR(N) or CHAR(1)
Why in this world someone will truncate the string to from 2 characters to 1 character just because he is not able to trim it? :?

what if you get a two character string in input? :?