Page 1 of 2

remove leading zeros in decimal field in sequential file

Posted: Mon Mar 16, 2009 4:31 pm
by UPS
Hi,
I am trying to remove the leading zeros in the decimal field in a sequential file stage.
for example...
if we have a value 000000000000000032.00
i want it to be changed as 32.00 .
please let me know if there is any way i can do it .
My input is a database and i am trying to put the data into a sequential file
THank you in advance

Posted: Mon Mar 16, 2009 5:08 pm
by ray.wurlod
You will need to change the data type to Varchar. DataStage will always add leading and trailing nonsignificant zeroes to Decimal data type when writing to text file or displaying through data browser. This proves that precision and scale are being handled properly.

Removing leading zeros

Posted: Tue Mar 17, 2009 8:54 am
by UPS
Even after converting into varchar...the leading zeros come up....is there any other way i cna get rid of the leading zeros

Posted: Tue Mar 17, 2009 9:08 am
by chulett
How exactly are you "converting into varchar"?

Posted: Tue Mar 17, 2009 1:43 pm
by us1aslam1us
I hope this will solve your issue..

Code: Select all

Trim(DecimalTostring(In.Col),'0','L')
sAM

C_format

Posted: Mon Jul 20, 2009 6:54 am
by abhilashnair
I observed that all posts related to this issue has the similar solution which says that we have to read the output as varchar and use DecimalToString in Transformer..

But when we were faces with this issue, one of my peers suggested using C_format option in the column properties...and it worked..Anyone here who disagrees?

Posted: Mon Jul 20, 2009 7:41 am
by priyadarshikunal
Use DecimalToString() with "suppress_zero" option. Something like

Code: Select all

DecimalTostring(In.Col, "suppress_zero")

EDIT: suppress should have two P's as mentioned by Ray.

Posted: Mon Jul 20, 2009 4:45 pm
by ray.wurlod
:idea: Double "P" in "suppress".

Posted: Tue Jul 21, 2009 4:44 am
by algfr
Correct me if I'm wrong but cannot you use Integer type instead of decimal ?

Posted: Tue Jul 21, 2009 5:10 am
by priyadarshikunal
Thanks Ray for correcting it.

you should only use it when the you don't have precision associated with the decimal value. Also integer datatype's storage (i think even bigint) may be insufficient to store decimal(38,0).

Posted: Tue Jul 21, 2009 5:30 am
by algfr
True, but maybe he could tell us how much he needs because 38 digits, man, that's a lot.

Posted: Tue Jul 21, 2009 6:11 am
by ragasambath
Hello,

The function is DecimalTostring(Decimal input, "supress_zero")

Before using this function covert your input to Decimal

Thanks

Ragasambath

Posted: Tue Jul 21, 2009 6:16 am
by ShaneMuir
If you use the "supress zero" option on the decimaltostring, it will remove zero's after the decimal also. So if the value was 32.000 it would come out as 32

Posted: Mon Sep 20, 2010 2:52 am
by PhilHibbs
Where is this documented?

Posted: Mon Sep 20, 2010 4:57 am
by priyadarshikunal
The function is documented in "Parallel Job Developer Guide" however the different rtypes are not really present there. The different options are documented in "Orchestrate Operator Reference" doc.