LPAD equivalent in DS

Post questions here relative to DataStage Server Edition for such areas as Server job design, DS Basic, Routines, Job Sequences, etc.

Moderators: chulett, rschirm, roy

Post Reply
rxs0005
Participant
Posts: 18
Joined: Fri Oct 07, 2005 4:29 am

LPAD equivalent in DS

Post by rxs0005 »

hi all

All i need to do is i have a column that is 5 characters long .

I need to LPAD it with 0's if its not 5 characters long

Input col = ABCD OUTPUT = 0ABCD

Input col = ijklm OUTPUT = ijklm


basically the oracle LPAD equivalent .


I found the

PadString function
Return the string padded with the optional pad character and optional length
string (string)
padlength (int32)
result (string)

but i cannot find it in the trasnfomer when i do the right click so i dont knwo what the input parameters are

thanks
rxs0005
ArndW
Participant
Posts: 16318
Joined: Tue Nov 16, 2004 9:08 am
Location: Germany
Contact:

Post by ArndW »

The function/derivation you are looking for is FMT(In.Column,'5"0"R')
rxs0005
Participant
Posts: 18
Joined: Fri Oct 07, 2005 4:29 am

Post by rxs0005 »

thanks that worked!
ray.wurlod
Participant
Posts: 54607
Joined: Wed Oct 23, 2002 10:52 pm
Location: Sydney, Australia
Contact:

Post by ray.wurlod »

It can also be represented as Fmt(InLink.Column, "R%5")
IBM Software Services Group
Any contribution to this forum is my own opinion and does not necessarily reflect any position that IBM may hold.
Marley777
Premium Member
Premium Member
Posts: 316
Joined: Tue Jan 27, 2004 3:26 pm

Post by Marley777 »

Hi, how do you do this on in a DataStage PX 7.5 job? Thanks!!
ray.wurlod
Participant
Posts: 54607
Joined: Wed Oct 23, 2002 10:52 pm
Location: Sydney, Australia
Contact:

Post by ray.wurlod »

Why didn't you ask in the parallel forum? :?

Assuming you have a string data type you would use something like

Code: Select all

Left("00000",5-Len(InLink.TheString)) : InLink.TheString
If the incoming data type is not string, you would need to convert it to string.
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