Leading zero's infront for negative values

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
dodda
Premium Member
Premium Member
Posts: 244
Joined: Tue May 29, 2007 11:31 am

Leading zero's infront for negative values

Post by dodda »

Hi eveyone,

I need some help regarding appending the leading zero's infront for negative values
My source file is a simple text file , which has a column QT of integer type of length 6.

The input data for QT is like
888
-3456
12
-22
And i have to map column QT to QTY with leading zeros and the target column QTY of varchar type of length 6

My desired ouput should be like
000888
-03456
000012
-00022

I used the following function in the transformer :::
Right("000000" : InLink.QT, 6)But iam getting output as

000888
0-3456
000012
000-22

Can anyone suggest the solution for this one.

Your help is greatly appreciated.

Thanks in advance,
dodda
mahadev.v
Participant
Posts: 111
Joined: Tue May 06, 2008 5:29 am
Location: Bangalore

Post by mahadev.v »

If in.Col[1,1] = "-" Then "-" : Right("000000" : trim(InLink.QT), 5) Else Right("000000" : InLink.QT, 6) . I am not sure of the trim syntax. You will have to trim the leading "-" sign. Use online help for that.
"given enough eyeballs, all bugs are shallow" - Eric S. Raymond
ray.wurlod
Participant
Posts: 54607
Joined: Wed Oct 23, 2002 10:52 pm
Location: Sydney, Australia
Contact:

Post by ray.wurlod »

Code: Select all

If Left(Col1,1) = "-" Then "-" : Right("000000" : Right(Col1,Len(Col1)-1)) Else Right("000000" : Col1)
IBM Software Services Group
Any contribution to this forum is my own opinion and does not necessarily reflect any position that IBM may hold.
Post Reply