Skip to main content
Announcements
A fresh, new look for the Data Integration & Quality forums and navigation! Read more about what's changed.
cancel
Showing results for 
Search instead for 
Did you mean: 
Anonymous
Not applicable

How to convert bigDecimal to double

Hello,
I have a AS400 database that contains data with decimal type.
when I loaded the data ,Talend convert the Decimal type to BigDecimal .
And for the destination I have a postgres database .
when I made the connection between the two databases using a tmap component. this error msg appears:
Exception in thread "main" java.lang.Error: Problèmes de compilation non résolus :
Non concordance de types : impossible de convertir de BigDecimal en double
Non concordance de types : impossible de convertir de BigDecimal en double
Non concordance de types : impossible de convertir de BigDecimal en double
0683p000009MDUq.png
Labels (3)
8 Replies
Anonymous
Not applicable
Author

hi asterisks,
first Talend use a Xml file to Map DB type to JavaType (also known as Talend Type) and 'vice-versa'.
There is no implicit cast between type.
So you can't change the way Talend Map conversion Type by Default.
You have to convert type if necessary ; for that purpose use tConvertType.
BE AWARE about java type for decimal and loosing precision with floating type like Float & Double
hope it helps
regards
laurent
Anonymous
Not applicable
Author

You will not losing any precision if you only transfer data also on Double.
You should use an expression in your tMap:
row1.my_big_decimal != null ? row1.my_big_decimal.doubleValue() : null
Anonymous
Not applicable
Author

hi all,
Because floating-point numbers have a limited number of digits, they cannot represent all real numbers accurately: when there are more digits than the format allows, the leftover ones are omitted - the number isrounded.
You will not losing any precision if you only transfer data also on Double

You mean if you make any calculation on decimal and JUST propagate value through the flows !?
regards
laurent
Anonymous
Not applicable
Author

hello Mr.JLOLLING,
Can you please tell me,where exactly I'll put the expression....
Regards,
Anonymous
Not applicable
Author

Hi,
Please have a look at screenshot
Best regards
Sabrina
0683p000009MDSP.png
Anonymous
Not applicable
Author

hello,
it works, thank you a lot
Best regards
Anonymous
Not applicable
Author

Hi,
Thanks for your feedback. Could you please click the "Set this topic as resolved" link which is right underneath your initial post? This way, other users will be informed that this thread has been resolved.
Many thanks
Best regards
Sabrina
Anonymous
Not applicable
Author

@jlolling
Thanks for the expression   
May you can give a short exaplaination what he expression does  
Will be helpful  
Additional: Could i use the expression for an Fieldlookup also or only for  mapping. 
Thanks in advance 
regards fireskyer