Do not input private or sensitive data. View Qlik Privacy & Cookie Policy.
Skip to main content

Announcements
Qlik Open Lakehouse is Now Generally Available! Discover the key highlights and partner resources here.
cancel
Showing results for 
Search instead for 
Did you mean: 
_AnonymousUser
Specialist III
Specialist III

BigDecimal to integer conversion

Hi,
I'm super new to Talend and am running into a problem while extracting data from an oracle database and loading it into a postgres db. I have a few columns that have use the oracle bigDecimal datatype without a precision. To me that meant that its a just a large integer (double) - the postgres db has the equivalent column using an integer datatype. When I try to directly move data through tMap I get an bigDecimal to integer conversion error.
In Java, I know we would use bigDecimalVar.intValue() to convert the bigDecimal into an integer. How do I implement this in tMap? I tried using the bigDecimalColumn.intValue() in the expression box but I get a Java lang error.
Help!
Thanks!
Labels (4)
7 Replies
_AnonymousUser
Specialist III
Specialist III
Author

This is the expression I'm trying to use:
row1.DS_PRS_ID.intValue()
Anonymous
Not applicable

If you get an Java compilation error this way than at first I would check if I get REAL a BigDecimal as object type.
Could you provide the error message?
Anonymous
Not applicable

hello all,
i want to convert BigDecimal to integer ,
I am using Integer.parseInt(row.columnname)
but its not working........
please provide solution for this.
Anonymous
Not applicable

Hi indra,
intValue() convert the big decimal to integer
row3.test.intValue()
Regards,
kumar
_AnonymousUser
Specialist III
Specialist III
Author

hello all,
i want to convert BigDecimal to integer ,
I am using Integer.parseInt(row.columnname)
but its not working........
please provide solution for this.
Anonymous
Not applicable

Hi prudvi,
Have you tried to use
row1.newColumn.intValue() //The type of newColumn is BigDecimal.
Best regards
Sabrina
Eva_Hamel
Contributor
Contributor

Hello,

This topic is quite old but I will answer it because people (like me) may look for an answer and find this topic.

Here is the solution I found : you can make a routine such as :

 

   public static Integer Integer(BigDecimal bd) {

      return bd.intValue();

   }

 

Then you can call this routine in Tmap or anywhere you need to convert Bigdecimal to Integer by typing {Routine_Name}.Integer({BigDecimal_Value})

Make sure the BigDecimal number you want to convert is convertible to Integer tho.

I'm quite new on Talend so maybe there is a better solution, but Routine is a very powerful tool that can solve many problems.

 

Cheers