Padding zero's before the value based on the data

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
DWH-M
Premium Member
Premium Member
Posts: 46
Joined: Thu Sep 06, 2007 5:26 am

Padding zero's before the value based on the data

Post by DWH-M »

HI

I have one requirement i am tring to load data into the target like:

my input data size is numeric(10), if i get the data like 25685, i need to load into the taget like 0000025685


if data is coming 5 digit , remaining preceeding zero's should come, if 2 digit data is coming 8 digit zero's should come.

please help me to know the resolution.

thanks in advance

suma
pandujoy
Participant
Posts: 70
Joined: Tue May 13, 2008 1:37 pm

Post by pandujoy »

Use a len(Str,"0" with column)
Ravi.K
Participant
Posts: 209
Joined: Sat Nov 20, 2010 11:33 pm
Location: Bangalore

Post by Ravi.K »

Try with below derivation.

Right('0000000000':Inputcol,10)
Cheers
Ravi K
pandujoy
Participant
Posts: 70
Joined: Tue May 13, 2008 1:37 pm

Post by pandujoy »

This is the best option :

Str("0",8-len(Column):Column
kaps
Participant
Posts: 452
Joined: Tue May 10, 2005 12:36 pm

Post by kaps »

FMT(Column,'8"0"L')
jwiles
Premium Member
Premium Member
Posts: 1274
Joined: Sun Nov 14, 2004 8:50 pm
Contact:

Post by jwiles »

Actually, Ravi's example using Right() is more efficient in this case as you're not having to call the Len() and Str() functions each time. The end result is the same.

If you must do zero-padding several times in a transformer and process millions of rows, you can see a distinct performance difference between the two methods.

Regards,
- james wiles


All generalizations are false, including this one - Mark Twain.
Post Reply