How to PAD with Leading Zeroes

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
ambasta
Participant
Posts: 93
Joined: Thu Jan 19, 2006 10:29 pm
Location: Bangalore

How to PAD with Leading Zeroes

Post by ambasta »

Hi All,
Can anyone please help me..
Source is having Varchar(10) and target is Char(10).My Requirement is...
any length of data till length 10 can come from source,and i need to pad this data with leading zeroes followed by that data so that length in target side is remain 10.
Ex.
if data is coming like 12345 then populate 0000012345,
if data is coming like 432 then populate it as 0000000432.
if data is coming like 1234567 then populate it as 0001234567.

Please help me.
ambasta
ArndW
Participant
Posts: 16318
Joined: Tue Nov 16, 2004 9:08 am
Location: Germany
Contact:

Post by ArndW »

I can think of a couple of approaches in a transform stage using string functions.
One would be

Code: Select all

STR('0',10-Len(In.String)):In.String
or

Code: Select all

RIGHT('0000000000':In.String,10)
to name just two methods.
meena
Participant
Posts: 430
Joined: Tue Sep 13, 2005 12:17 pm

Re: How to PAD with Leading Zeroes

Post by meena »

Hi,
Try this FMT("input column", "10'0'R").
Source is having Varchar(10) and target is Char(10).My Requirement is...
any length of data till length 10 can come from source,and i need to pad this data with leading zeroes followed by that data so that length in target side is remain 10.
Ex.
if data is coming like 12345 then populate 0000012345,
ambasta
Participant
Posts: 93
Joined: Thu Jan 19, 2006 10:29 pm
Location: Bangalore

Post by ambasta »

Thanx a lot ArndW for this kind help.
This is working for me.
ambasta
ray.wurlod
Participant
Posts: 54607
Joined: Wed Oct 23, 2002 10:52 pm
Location: Sydney, Australia
Contact:

Post by ray.wurlod »

Is FMT function available in parallel jobs?
IBM Software Services Group
Any contribution to this forum is my own opinion and does not necessarily reflect any position that IBM may hold.
ambasta
Participant
Posts: 93
Joined: Thu Jan 19, 2006 10:29 pm
Location: Bangalore

Post by ambasta »

Hi Ray,
i can't find any function called FMT in parallel jobs.I think it is not available.
ambasta
Post Reply