Decimal issue

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
somu_june
Premium Member
Premium Member
Posts: 439
Joined: Wed Sep 14, 2005 9:28 am
Location: 36p,reading road

Decimal issue

Post by somu_june »

Hi All,

I have Amount with Varchar(21) and it's getting data as 11302.06 and 0.00 in two records and I'm converting it to Decimal (21,5). I'm using a function

StringToDecimal(SvValueAddedAmt,"trunc_zero")

but I'm getting data as 0000000000011302.06000 and 0000000000000000.00000

Is there a way that I can get output as 11302.06000 and 0.00000


Thanks,
Somaraju
somaraju
ray.wurlod
Participant
Posts: 54607
Joined: Wed Oct 23, 2002 10:52 pm
Location: Sydney, Australia
Contact:

Post by ray.wurlod »

Not if your data type is Decimal. DataStage shows leading and trailing zeroes to confirm that precision and scale have been handled correctly.

You can remove these by changing the data type to VarChar.
IBM Software Services Group
Any contribution to this forum is my own opinion and does not necessarily reflect any position that IBM may hold.
chulett
Charter Member
Charter Member
Posts: 43085
Joined: Tue Nov 12, 2002 4:34 pm
Location: Denver, CO

Post by chulett »

Why not just append the needed number of zeroes to the string?
-craig

"You can never have too many knives" -- Logan Nine Fingers
Shruthi
Participant
Posts: 74
Joined: Sun Oct 05, 2008 10:59 pm
Location: Bangalore

Post by Shruthi »

You can give suppress_zero after conversion. This would result in 11302.06.

If you want to ginore only zero's in mantissa, then convert it to varchar again and trim zero's on the left.

Hope this helps!
richdhan
Premium Member
Premium Member
Posts: 364
Joined: Thu Feb 12, 2004 12:24 am

Post by richdhan »

Hi,

Pls search for my posts on DecimalToString. Along with the DecimalToString you have to use the Field and Trim options to remove the unwanted zeros.

HTH
--Rich
IBM Certified DataStage Solution Developer | Teradata Certified Master
iHijazi
Participant
Posts: 45
Joined: Sun Oct 24, 2010 12:05 am

Post by iHijazi »

Of course you'd have it look like that!

Here's what to do: in the stage before that stage which got the varchar type, it's either numeric or decimal, correct?

Now, in that stage, clear the precision or limit it.

If the stage before it also have the type of varchar, keep tracking back the stages till you hit one that is NOT varchar and is decimal/numeic.

Happy DataStaging ;)
Post Reply