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

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

Labels (2)
11 Replies
olektrolek
Contributor

try:
(new Integer(yourvalue)).toString()
hope this helps
Anonymous
Not applicable
Author

Or you can use ""+REF.REF_ID
0683p000009MA9p.png
Anonymous
Not applicable
Author

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?
Anonymous
Not applicable
Author

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.
Anonymous
Not applicable
Author

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.
Anonymous
Not applicable
Author

Hi
Try this:
String.valueOf(REF.REF_ID)
Best regards
shong
Anonymous
Not applicable
Author

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.
ashok5
Contributor III

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

or you can Google it to find all the java conversions