Pad leading zeroes to a smallint field

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
Marley777
Premium Member
Premium Member
Posts: 316
Joined: Tue Jan 27, 2004 3:26 pm

Pad leading zeroes to a smallint field

Post by Marley777 »

Hi, is there a way to pad leading zeroes to a smallint field within a prallel job? Target is also smallint. Can have values 01 or 1. We always want a leading zeroes so need to make sure the field is always padded, so the 1 become 01. Thanks for your help.
vivekgadwal
Premium Member
Premium Member
Posts: 457
Joined: Tue Sep 25, 2007 4:05 pm

Post by vivekgadwal »

Vivek Gadwal

Experience is what you get when you didn't get what you wanted
n.parameswara.reddy@accen
Participant
Posts: 40
Joined: Mon May 18, 2009 5:22 am

Post by n.parameswara.reddy@accen »

use str function for pad chars leading or trailing
Marley777
Premium Member
Premium Member
Posts: 316
Joined: Tue Jan 27, 2004 3:26 pm

Post by Marley777 »

my target and source is an integer. How can I pad leading zeroes when my source and target datatypes are integer?
n.parameswara.reddy@accen
Participant
Posts: 40
Joined: Mon May 18, 2009 5:22 am

Post by n.parameswara.reddy@accen »

Marley777 wrote:my target and source is an integer. How can I pad leading zeroes when my source and target datatypes are integer?
use transformer, Stage variable , convert into char or var-char , then pad it, then again covert into intiger
ray.wurlod
Participant
Posts: 54607
Joined: Wed Oct 23, 2002 10:52 pm
Location: Sydney, Australia
Contact:

Post by ray.wurlod »

Integers are stored in binary form. You can not expect leading zeroes to be preserved. Only the value is stored. To display with leading zeroes you must use a string data type.
IBM Software Services Group
Any contribution to this forum is my own opinion and does not necessarily reflect any position that IBM may hold.
mhester
Participant
Posts: 622
Joined: Tue Mar 04, 2003 5:26 am
Location: Phoenix, AZ
Contact:

Post by mhester »

If nothing else this thread is good for a laugh :shock:
Marley777
Premium Member
Premium Member
Posts: 316
Joined: Tue Jan 27, 2004 3:26 pm

Post by Marley777 »

Changed output to character. This works for us. Thanks everyone.
mhester
Participant
Posts: 622
Joined: Tue Mar 04, 2003 5:26 am
Location: Phoenix, AZ
Contact:

Post by mhester »

I might suggest that whomever set the resolution status of this thread to "WORKAROUND" change it to "RESOLVED" since workaraound implies that there is a problem with small int and integers in that they cannot be zero padded.

Converting it to a character and padding that STRING with zero's is the only solution and is not a workaround.
Marley777
Premium Member
Premium Member
Posts: 316
Joined: Tue Jan 27, 2004 3:26 pm

Post by Marley777 »

Changed to resolved. Thanks.
Post Reply