remove leading zeros in decimal field in sequential file

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

UPS
Premium Member
Premium Member
Posts: 56
Joined: Tue Oct 10, 2006 12:18 pm
Location: New Jersey

remove leading zeros in decimal field in sequential file

Post 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
ray.wurlod
Participant
Posts: 54607
Joined: Wed Oct 23, 2002 10:52 pm
Location: Sydney, Australia
Contact:

Post 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.
IBM Software Services Group
Any contribution to this forum is my own opinion and does not necessarily reflect any position that IBM may hold.
UPS
Premium Member
Premium Member
Posts: 56
Joined: Tue Oct 10, 2006 12:18 pm
Location: New Jersey

Removing leading zeros

Post 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
chulett
Charter Member
Charter Member
Posts: 43085
Joined: Tue Nov 12, 2002 4:34 pm
Location: Denver, CO

Post by chulett »

How exactly are you "converting into varchar"?
-craig

"You can never have too many knives" -- Logan Nine Fingers
us1aslam1us
Charter Member
Charter Member
Posts: 822
Joined: Sat Sep 17, 2005 5:25 pm
Location: USA

Post by us1aslam1us »

I hope this will solve your issue..

Code: Select all

Trim(DecimalTostring(In.Col),'0','L')
sAM
I haven't failed, I've found 10,000 ways that don't work.
Thomas Alva Edison(1847-1931)
abhilashnair
Participant
Posts: 284
Joined: Fri Oct 13, 2006 4:31 am

C_format

Post 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?
priyadarshikunal
Premium Member
Premium Member
Posts: 1735
Joined: Thu Mar 01, 2007 5:44 am
Location: Troy, MI

Post 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.
Last edited by priyadarshikunal on Mon Sep 20, 2010 4:59 am, edited 1 time in total.
Priyadarshi Kunal

Genius may have its limitations, but stupidity is not thus handicapped. :wink:
ray.wurlod
Participant
Posts: 54607
Joined: Wed Oct 23, 2002 10:52 pm
Location: Sydney, Australia
Contact:

Post by ray.wurlod »

:idea: Double "P" in "suppress".
IBM Software Services Group
Any contribution to this forum is my own opinion and does not necessarily reflect any position that IBM may hold.
algfr
Participant
Posts: 106
Joined: Fri Sep 09, 2005 7:42 am

Post by algfr »

Correct me if I'm wrong but cannot you use Integer type instead of decimal ?
priyadarshikunal
Premium Member
Premium Member
Posts: 1735
Joined: Thu Mar 01, 2007 5:44 am
Location: Troy, MI

Post 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).
Priyadarshi Kunal

Genius may have its limitations, but stupidity is not thus handicapped. :wink:
algfr
Participant
Posts: 106
Joined: Fri Sep 09, 2005 7:42 am

Post by algfr »

True, but maybe he could tell us how much he needs because 38 digits, man, that's a lot.
ragasambath
Participant
Posts: 12
Joined: Wed Oct 03, 2007 9:11 am
Location: London

Post by ragasambath »

Hello,

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

Before using this function covert your input to Decimal

Thanks

Ragasambath
ShaneMuir
Premium Member
Premium Member
Posts: 508
Joined: Tue Jun 15, 2004 5:00 am
Location: London

Post 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
PhilHibbs
Premium Member
Premium Member
Posts: 1044
Joined: Wed Sep 29, 2004 3:30 am
Location: Nottingham, UK
Contact:

Post by PhilHibbs »

Where is this documented?
Phil Hibbs | Capgemini
Technical Consultant
priyadarshikunal
Premium Member
Premium Member
Posts: 1735
Joined: Thu Mar 01, 2007 5:44 am
Location: Troy, MI

Post 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.
Priyadarshi Kunal

Genius may have its limitations, but stupidity is not thus handicapped. :wink:
Post Reply