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.
Removing zeros for decimal values
Moderators: chulett, rschirm, roy
Re: Removing zeros for decimal values
Try DecimalToString function with "suppress_zero" parameter
-
- Participant
- Posts: 11
- Joined: Mon Mar 17, 2008 3:14 pm
Re: Removing zeros for decimal values
Try this function
Trim(DecimalToString(Coloumn_name,"suppress_zero"), "0", "L")
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.
-
- Participant
- Posts: 54607
- Joined: Wed Oct 23, 2002 10:52 pm
- Location: Sydney, Australia
- Contact:
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.
Any contribution to this forum is my own opinion and does not necessarily reflect any position that IBM may hold.
Ray,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 ...
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.....
Re: Removing zeros for decimal values
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"
-
- Participant
- Posts: 54607
- Joined: Wed Oct 23, 2002 10:52 pm
- Location: Sydney, Australia
- Contact:
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.
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.
Any contribution to this forum is my own opinion and does not necessarily reflect any position that IBM may hold.