DecimalToString zero pad to the left

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
venkycool
Participant
Posts: 59
Joined: Fri Feb 16, 2007 12:24 am
Location: USA

DecimalToString zero pad to the left

Post by venkycool »

Hello,

I am trying to use DecimalToString finction because the source columns field is decimal and it is mapped to target field which is always char.

Incoming data is like 0000002.22 is what the file has now...10 bytes with a decimal. I want to take the decimal out an the final should be zero pad to the left.

it should be "000000999" ... 9 bytes and no decimal in target.

Tried left("000000000" : DecimalToString(ColName,"suppress_zero") ,9) - didnt work as I am getting the scale of 2 still

Any help?

Thanks in advance!!
Suriv
No one is perfect... that's why pencils have erasers
venkycool
Participant
Posts: 59
Joined: Fri Feb 16, 2007 12:24 am
Location: USA

Post by venkycool »

Sorry for the typo

it should be "000000222" 9 bytes and no decimal in target.
Suriv
No one is perfect... that's why pencils have erasers
jwiles
Premium Member
Premium Member
Posts: 1274
Joined: Sun Nov 14, 2004 8:50 pm
Contact:

Post by jwiles »

You can do this in at least a few ways:

- Multiply by 100 and convert to integer, then put into a string with left zero padding.

- Store the string with decimal point in a stage variable and use left() and right() to grab all but the decimal point

- Use the Convert() function to replace the "." with "" (empty string) in the string

All three will work, but the last is probably the simplest :)

Regards,
- james wiles


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