DecimalToString Eliminating Right Zeros

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
myukassign
Premium Member
Premium Member
Posts: 238
Joined: Fri Jul 25, 2008 8:55 am

DecimalToString Eliminating Right Zeros

Post by myukassign »

Hi ,

I have values coming like this. My datatype is Decimal(5,2)

00023.0200
00035.20

I am using the following function and assing to a Varchar field.
DecimalToString(MyVar,"suppress_zero")

The issue is first value it fine..my result is 23.02
Second value is killing my peace, its coming like 35.2

Can anyone give me a tip to keep that leading zero and get value like this 35.20

Many thanks in advance
gssr
Participant
Posts: 243
Joined: Fri Jan 09, 2009 12:51 am
Location: India

Post by gssr »

What is your Job Flow?
Is your source file is any database or sequential file?
What datatype you are going to load that column (Decimal or String)?
RAJ
Sainath.Srinivasan
Participant
Posts: 3337
Joined: Mon Jan 17, 2005 4:49 am
Location: United Kingdom

Post by Sainath.Srinivasan »

Or how about

Code: Select all

yourString[1,1] : Trim(yourString[2,9999], '0', 'L')
Sairam
Participant
Posts: 42
Joined: Tue Nov 11, 2003 1:09 pm

Post by Sairam »

Left('00' :DecimalToString(MyVar,"fix_zero,suppress_zero"),2)

Let me know if it works
Sairam
Participant
Posts: 42
Joined: Tue Nov 11, 2003 1:09 pm

Post by Sairam »

Sairam wrote:Left('00' :DecimalToString(MyVar,"fix_zero,suppress_zero"),2)

Let me know if it works
Please find the correct expression

Left('00' :DecimalToString(MyVar,"fix_zero,suppress_zero"), Len(MyVar))
ruf888
Participant
Posts: 20
Joined: Wed May 13, 2009 1:14 am
Location: Germany

Re: DecimalToString Eliminating Right Zeros

Post by ruf888 »

I have had the same problem as you and searched the forum for a solution but cannot find anything which did work. I made several tests by myself and have found out a solution which will work for keeping the zeros after decimal as well as the original digits after the decimal :

Suppose we have 2 values :

23,00
25,12

We must use a function which will keep the 12 after decimal and for the 00 :
I used the following formula :

IF Index(DecimalToString(Price,"fix_zero,suppress_zero"), '.',1)=0 THEN
DecimalToString(Price_If,"fix_zero,suppress_zero") : '.00' ELSE DecimalToString(Price_If,"fix_zero,suppress_zero")


With this formula we get the decimal value as char

23.00
25.12

I hope this will help all who are having the same problem.
Post Reply