trim function not working

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
sanoojk
Participant
Posts: 36
Joined: Wed Dec 19, 2007 3:54 am

trim function not working

Post 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
priyadarshikunal
Premium Member
Premium Member
Posts: 1735
Joined: Thu Mar 01, 2007 5:44 am
Location: Troy, MI

Post by priyadarshikunal »

change the datatype to varchar or do this calculation in varchar stage varibale and see if it works.
Priyadarshi Kunal

Genius may have its limitations, but stupidity is not thus handicapped. :wink:
chulett
Charter Member
Charter Member
Posts: 43085
Joined: Tue Nov 12, 2002 4:34 pm
Location: Denver, CO

Post 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.
-craig

"You can never have too many knives" -- Logan Nine Fingers
rahcomp
Participant
Posts: 11
Joined: Wed Apr 18, 2012 2:13 pm

Re: trim function not working

Post 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
Last edited by rahcomp on Thu Apr 19, 2012 10:41 am, edited 1 time in total.
Rahul
DS Lover
priyadarshikunal
Premium Member
Premium Member
Posts: 1735
Joined: Thu Mar 01, 2007 5:44 am
Location: Troy, MI

Re: trim function not working

Post 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? :?
Priyadarshi Kunal

Genius may have its limitations, but stupidity is not thus handicapped. :wink:
Post Reply