Page 1 of 1

Pad leading zeroes to a smallint field

Posted: Mon Oct 25, 2010 11:02 am
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.

Posted: Mon Oct 25, 2010 11:23 am
by vivekgadwal

Posted: Mon Oct 25, 2010 11:29 am
by n.parameswara.reddy@accen
use str function for pad chars leading or trailing

Posted: Mon Oct 25, 2010 11:51 am
by Marley777
my target and source is an integer. How can I pad leading zeroes when my source and target datatypes are integer?

Posted: Mon Oct 25, 2010 11:58 am
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

Posted: Mon Oct 25, 2010 12:59 pm
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.

Posted: Mon Oct 25, 2010 1:45 pm
by mhester
If nothing else this thread is good for a laugh :shock:

Posted: Wed Oct 27, 2010 2:01 pm
by Marley777
Changed output to character. This works for us. Thanks everyone.

Posted: Wed Oct 27, 2010 2:05 pm
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.

Posted: Wed Oct 27, 2010 2:10 pm
by Marley777
Changed to resolved. Thanks.