Page 1 of 1

trim leading 0's from decimal

Posted: Mon Sep 18, 2006 1:53 am
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.

Posted: Mon Sep 18, 2006 2:18 am
by sravanthi
try multiplying with 1 and see if it works

Posted: Mon Sep 18, 2006 2:29 am
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 !!!

Posted: Mon Sep 18, 2006 3:03 am
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.

Posted: Mon Sep 18, 2006 10:16 am
by kris007
Check this post

It might be of help.

Posted: Mon Sep 18, 2006 5:49 pm
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.