Conversion in Transformer

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
Rajesh Jale
Premium Member
Premium Member
Posts: 6
Joined: Fri Mar 14, 2014 2:29 am

Conversion in Transformer

Post by Rajesh Jale »

Hi,

I have source column Code char(9) which contains code in both forms numbers and letters like 161,ADG.
I'm using transformer where i have condition that when code is 112 then current timestamp else column2

Condition : if code = 161 then CurrentTimestamp() else column2

But im facing a problem when using above condition, its unable to match the number since its defined as char. May I know whats the best way to convert char, so that it can match both numbers and letters in the condition.

Can someone help me with this.

Regards,
Rajesh
Regards,
Rajesh
qt_ky
Premium Member
Premium Member
Posts: 2895
Joined: Wed Aug 03, 2011 6:16 am
Location: USA

Post by qt_ky »

Have you tried use the Index function?

http://www-01.ibm.com/support/knowledge ... tions.html
Choose a job you love, and you will never have to work a day in your life. - Confucius
chulett
Charter Member
Charter Member
Posts: 43085
Joined: Tue Nov 12, 2002 4:34 pm
Location: Denver, CO

Post by chulett »

It's not unable to match it, it should be perfectly capable of doing that but you're right the CHAR part does make it a little trickier. I would suggest a couple of things, one or both may help.

Test for the character value "161" rather than the number...i.e. use quotes so it does a string match rather than feel a need to convert one side or the other. And since the CHAR carries trailing spaces you may need to trim the field in the comparison but I'm thinking just that first step may solve things for you.
-craig

"You can never have too many knives" -- Logan Nine Fingers
vibwipro
Participant
Posts: 40
Joined: Thu Jan 24, 2013 7:34 am

Post by vibwipro »

When ever data type char is defined then it will Pad spaces to existing data to make compatible with length of field.

So use Substring function to cut actual data characters form a space padded string. :idea:
Rajesh Jale
Premium Member
Premium Member
Posts: 6
Joined: Fri Mar 14, 2014 2:29 am

Post by Rajesh Jale »

Trim works, also tried using double quotes like "161" but didnt help me. However trim works perfectly. Thanks Craig for solution.
Regards,
Rajesh
Post Reply