trim leading 0's from decimal

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
parbados
Participant
Posts: 17
Joined: Fri Dec 02, 2005 8:33 am

trim leading 0's from decimal

Post by parbados »

Hi,

I have a integer(4) comming into a transformer stage which I want to convert to a varchar. I cannot use a inttostring because there is no function (or is there ?).

I therfore use DecimalToString to convert to a varchar(64) however it has leading and trailing zeros i.e. 7869 comes out as 0000000007869.00000000

How can I trim this I tried to use
PRODUCT_NO= string_trim["0", begin, end](PRODUCT_NO) in a modify statement however this does not work can someone help please.
sravanthi
Participant
Posts: 83
Joined: Fri Jun 02, 2006 5:37 am

Post by sravanthi »

try multiplying with 1 and see if it works
sravanthi
parbados
Participant
Posts: 17
Joined: Fri Dec 02, 2005 8:33 am

Post by parbados »

Hi,

Thanks for the reply how would I do that in the transformer/ modify stage please can you sow me the code perhaps.

I am very new to this game !!!
kumar_s
Charter Member
Charter Member
Posts: 5245
Joined: Thu Jun 16, 2005 11:00 pm

Post by kumar_s »

You can use Trim function in Transformer, but you can directly map Integer column into varchar via transformer. DataStage will do the implicit conversion for you.
Impossible doesn't mean 'it is not possible' actually means... 'NOBODY HAS DONE IT SO FAR'
kris007
Charter Member
Charter Member
Posts: 1102
Joined: Tue Jan 24, 2006 5:38 pm
Location: Riverside, RI

Post by kris007 »

Check this post

It might be of help.
Kris

Where's the "Any" key?-Homer Simpson
ray.wurlod
Participant
Posts: 54607
Joined: Wed Oct 23, 2002 10:52 pm
Location: Sydney, Australia
Contact:

Post by ray.wurlod »

The Data Browser puts leading and trailing zeroes on Decimal data so that you can be user that precision and scale are being handled correctly. When stored - for example in a database table - the leading and trailing zeroes are not significant. It is only an issue if you want to write to text files. In that case, change data type to VarChar.
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