leading zeros infront

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 zeros infront

Post by dodda »

Hi,

I have a input file .txt, which has a column QT of integer type of length 6.

The input data for QT is like
888
3456
12
And i want to map column QT to QTY with leading zeros and the target column QTY should also be Integer type of length 6

My desired ouput should be like
000888
003456
000012

Can any one help for this?

Thanks in advance,
dodda
ray.wurlod
Participant
Posts: 54607
Joined: Wed Oct 23, 2002 10:52 pm
Location: Sydney, Australia
Contact:

Post by ray.wurlod »

Integers do not have leading zeroes. Integers are stored in a binary format. If you want leading zeroes then your target field needs to be a string. In that case an appropriate expression to use is something like

Code: Select all

Right("000000" : InLink.QT, 6)
IBM Software Services Group
Any contribution to this forum is my own opinion and does not necessarily reflect any position that IBM may hold.
gnan_gun
Participant
Posts: 30
Joined: Thu Aug 02, 2007 5:31 am
Location: Mumbai, India

Re: leading zeros infront

Post by gnan_gun »

HI,

Ray's point is correct. U have to change the datatype to varchar/char.

and have to use following function in transformer derivation of that column

Str('0', 6-Len(Trim(DSLink.columnname))):DSLink.columnname
ray.wurlod
Participant
Posts: 54607
Joined: Wed Oct 23, 2002 10:52 pm
Location: Sydney, Australia
Contact:

Post by ray.wurlod »

They don't have to use that expression. Mine is more efficient.
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