How to pad leading zero to string

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
nirdesh2
Participant
Posts: 56
Joined: Thu Nov 20, 2008 12:18 pm
Location: Noida

How to pad leading zero to string

Post by nirdesh2 »

Hi,

My source data is 123 and datatype is varchar2 and length is 10
I want to store it as 0000000123 in the target data with datatype varchar2 and length 10.
Nirdesh Kumar
LenGreenwood
Premium Member
Premium Member
Posts: 37
Joined: Mon Dec 08, 2008 4:02 am
Location: Milton Keynes, UK

Post by LenGreenwood »

In a Transformer derivation expression, you could try:

Code: Select all

("0000000000":link.col)[10]
That is, you prepend 10 zeroes to the start of your data, then substring the right-most 10 characters.

Syntax is the same in both Server and Parallel jobs.
chulett
Charter Member
Charter Member
Posts: 43085
Joined: Tue Nov 12, 2002 4:34 pm
Location: Denver, CO

Post by chulett »

Basically the same technique with a different function:

Code: Select all

Right("0000000000" : link.col, 10)
:wink:
-craig

"You can never have too many knives" -- Logan Nine Fingers
Post Reply