Page 1 of 1

Decimal Rounding Problem

Posted: Sun Jul 22, 2007 3:45 pm
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.

Posted: Sun Jul 22, 2007 7:38 pm
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.

Re: Decimal Rounding Problem

Posted: Sun Jul 22, 2007 8:09 pm
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)

Posted: Sun Jul 22, 2007 10:46 pm
by balajisr
Change your specification to

Code: Select all

NEW_Price:Decimal[12,2] = decimal_from_decimal [round_inf] (PRICE)
This should work.

Posted: Mon Jul 23, 2007 8:17 am
by somu_june
Hi,


Thanks GUYS for helping me .








Thanks,
SomaRaju