One Star

Convert Integer to String

I need to convert a primary key Interger to a String.
In the tMap I have written: (REF.REF_ID).toString() but the following error appears: "cannot invoke toString() on the primitive type int".
How can I convert it?
Thanks

9 REPLIES
One Star

Re: Convert Integer to String

try:
(new Integer(yourvalue)).toString()
hope this helps
One Star

Re: Convert Integer to String

Or you can use ""+REF.REF_ID
Smiley Wink
Employee

Re: Convert Integer to String

I see the "Perl" tag associated to this topic, but I don't think you're using a Perl project as Perl do this kind of conversion automatically. Can you confirm you're using Java?
One Star

Re: Convert Integer to String

Excuse me for the wrong information: my project is in java!
The solution (new Integer(REF.REF_ID)).toString() seems to work.
I had tried the: ""+REF.REF_ID without success!!
Thanks to every body.
One Star

Re: Convert Integer to String

I have replied to quick.
With the expression (new Integer(REF.REF_ID)).toString() the tMap expression builder don't make an error anymore. But the tMap component falls in error. The convertion of interger to string for a primary key is not possible.
Community Manager

Re: Convert Integer to String

Hi
Try this:
String.valueOf(REF.REF_ID)
Best regards
shong
----------------------------------------------------------
Talend | Data Agility for Modern Business
One Star

Re: Convert Integer to String

hi Shong, I am facing similar issue (converting string to char). My input schema is string/char and output schema is char column from OracleSP. It says datatype/argument mismatch when I run the job. Pls suggest.
One Star

Re: Convert Integer to String

Hi Pratik
you can use tconvertType component for converting column of one data type to other data type in talend
Regards
Ashok 
One Star

Re: Convert Integer to String

or you can Google it to find all the java conversions