Decimal Rounding Problem

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 Rounding Problem

Post by somu_june »

Hi,


I want to Round the decimal values to the nearest decimal value. I have a record with PRICE value = 13437.567 from input and it has Decimal (12,3) and I want output as 13437.57 and the output metadata is Decimal(12,2) . I used modify stage to achieve this

In Specification I mentioned

NEW_Price:Decimal = decimal_from_decimal [round_inf] (PRICE)


But Iam getting an NULL output


Thanks,
SomaRaju.
somaraju
JoshGeorge
Participant
Posts: 612
Joined: Thu May 03, 2007 4:59 am
Location: Melbourne

Post by JoshGeorge »

Have you tried mapping decimal 12,3 to target decimal 12,2. Most of the cases it does rounding to the nearest value by default (Without using modify stage itself). If target is seq file in the 'edit metadata' option (which you get by clicking on left tab of field properties) you have an option to specify decimal type where you can tell how to round the source field to fit into the destination decimal when importing to a decimal.
Joshy George
<a href="http://www.linkedin.com/in/joshygeorge1" ><img src="http://www.linkedin.com/img/webpromo/bt ... _80x15.gif" width="80" height="15" border="0"></a>
Zhang Bo
Participant
Posts: 15
Joined: Sun Jul 15, 2007 9:22 pm

Re: Decimal Rounding Problem

Post by Zhang Bo »

i saw a warning like this,When binding output interface field "Price" to field "New_Price": Conversion from source type "decimal[12,3]" to result type "decimal[1,0]": Possible range limitation.That may be the root cause you got Null value.
you can use a transformer stage,in derivation it's *DecimalToDecimal(DSLink3.Price,"round_inf")*,and output you can choose decimal(12,2).
However,i don't know to achieve this by modify stage,i don't know how to specify the output column option,e.g.decimal(12,2)
MaDFroG
balajisr
Charter Member
Charter Member
Posts: 785
Joined: Thu Jul 28, 2005 8:58 am

Post by balajisr »

Change your specification to

Code: Select all

NEW_Price:Decimal[12,2] = decimal_from_decimal [round_inf] (PRICE)
This should work.
somu_june
Premium Member
Premium Member
Posts: 439
Joined: Wed Sep 14, 2005 9:28 am
Location: 36p,reading road

Post by somu_june »

Hi,


Thanks GUYS for helping me .








Thanks,
SomaRaju
somaraju
Post Reply