Removing zeros for decimal values

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
dodda
Premium Member
Premium Member
Posts: 244
Joined: Tue May 29, 2007 11:31 am

Removing zeros for decimal values

Post by dodda »

Hi all,


I need some help regarding removing zeros for decimal values.

My source is oracle database. iam having one column QTY of decimal datatype(38,10)
And my target is .txt file and QTY column is of string type.
My input data is ::::

0000000000000000000000000010.1000000000
0000000000000000000000000020.0200000000

I have to produce in this format::

10.1
20.02

Plz help in getting the outptut.

Your help is greatly appreciated.
dsusr
Premium Member
Premium Member
Posts: 104
Joined: Sat Sep 03, 2005 11:30 pm

Re: Removing zeros for decimal values

Post by dsusr »

Try DecimalToString function with "suppress_zero" parameter
ppavani_km
Participant
Posts: 11
Joined: Mon Mar 17, 2008 3:14 pm

Re: Removing zeros for decimal values

Post by ppavani_km »

Try this function
Trim(DecimalToString(Coloumn_name,"suppress_zero"), "0", "L")

dodda wrote:Hi all,


I need some help regarding removing zeros for decimal values.

My source is oracle database. iam having one column QTY of decimal datatype(38,10)
And my target is .txt file and QTY column is of string type.
My input data is ::::

0000000000000000000000000010.1000000000
0000000000000000000000000020.0200000000

I have to produce in this format::

10.1
20.02

Plz help in getting the outptut.

Your help is greatly appreciated.
neena
Participant
Posts: 90
Joined: Mon Mar 31, 2003 4:32 pm

Hi

Post by neena »

Try this DecimalToString(Column_name,""fix_zero,suppress_zero") and change the output Column data type to Varchar.
ray.wurlod
Participant
Posts: 54607
Joined: Wed Oct 23, 2002 10:52 pm
Location: Sydney, Australia
Contact:

Post by ray.wurlod »

If the data type is Decimal you can not remove the non-significant zeroes, because they don't actually exist. They are an artifact of how DataStage displays decimal numbers to prove that precision and scale are being handled correctly. Internally Decimal data type is stored in a binary format.
IBM Software Services Group
Any contribution to this forum is my own opinion and does not necessarily reflect any position that IBM may hold.
dsusr
Premium Member
Premium Member
Posts: 104
Joined: Sat Sep 03, 2005 11:30 pm

Post by dsusr »

ray.wurlod wrote:If the data type is Decimal you can not remove the non-significant zeroes, because they don't actually exist. They are an artifact of how DataStage displays decimal numbers to prove that precision an ...
Ray,

Since the person has the target column as String so I suppose he can easily remove the data from Source Decimal column by using the DecimalToString funtion.

Let me know if I am wrong.....
AKUMAR21
Participant
Posts: 30
Joined: Fri Jul 20, 2007 12:44 am
Location: Chennai

Re: Removing zeros for decimal values

Post by AKUMAR21 »

The simplest way to deal with it is to change the dataype of the column QTY to float with scale 2. It will do the required conversion without need of using any functions.
"In god we trust; rest all we virus scan"
ray.wurlod
Participant
Posts: 54607
Joined: Wed Oct 23, 2002 10:52 pm
Location: Sydney, Australia
Contact:

Post by ray.wurlod »

If the data type of the output is string, then DecimalToString() may or may not be needed. It may be able to occur as an implicit conversion.

In that case, you could get rid of leading and trailing zero characters with a Trim() function.
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