Double to Decimal Data Type 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
ds2000
Premium Member
Premium Member
Posts: 109
Joined: Sun Apr 22, 2007 7:25 pm
Location: ny

Double to Decimal Data Type Issue

Post by ds2000 »

My source is double data type and using dFloatToDecimal function to send to target column decimal(16,12), i get warning message for the source data value of 13456.123456789012 and its displayed as zeroes but when i change target column to decimal(16,11) no warning but value is rounded. Even if i increase the size to decimal(20,20) i see zeroes there only. i want to understand How is data stored in decimal in datastage and how can i fix it, if anyone can comment please.

Thanks in advance.
SURA
Premium Member
Premium Member
Posts: 1229
Joined: Sat Jul 14, 2007 5:16 am
Location: Sydney

Re: Double to Decimal Data Type Issue

Post by SURA »

First point

Your sample data is 13456.123456789012
Your target column decimal(16,12) /decimal(16,11)

It is not correct. Is it the real data or you gives some data for example?
Thanks
Ram
----------------------------------
Revealing your ignorance is fine, because you get a chance to learn.
qt_ky
Premium Member
Premium Member
Posts: 2895
Joined: Wed Aug 03, 2011 6:16 am
Location: USA

Post by qt_ky »

Precision is number of digits and scale is number of digits to the right of the decimal. Your sample number, 13456.123456789012, has a precision of 17 and a scale of 12, which is decimal(17,12).
Choose a job you love, and you will never have to work a day in your life. - Confucius
ds2000
Premium Member
Premium Member
Posts: 109
Joined: Sun Apr 22, 2007 7:25 pm
Location: ny

Post by ds2000 »

Thanks qt_ky and SURA to to explain the storage of numeric.

My actual data value was 14656.495444480958, that becomes Numeric(17, 12) and it works fine. I have increased the total precision to 20 to fit max value that i found in the table.
ds2000
Premium Member
Premium Member
Posts: 109
Joined: Sun Apr 22, 2007 7:25 pm
Location: ny

Final Conclusion

Post by ds2000 »

To get rid of this Warning:
APT_CombinedOperatorController,2: Conversion error calling conversion routine decimal_from_dfloat data may have been lost

and Following this rule:
Precision is number of digits and scale is number of digits to the right of the decimal.

scale/decimal value (right part of decimal) first uses total no of precision/digits size as defined in the column defintion and remaining precision/digits size is provided for left part of decimal.

Example:

12345.123456789012 will fit into Numeric(17, 12) because total Precision/Digits size is 17 and after decimal size is 12 and before decimal size is 5.

this value willnot fit into Numeric(16, 12) as per rule and will issue above mentioned warnig.
Post Reply