One Star

How to convert String To integer?

hi,
I have attached my job.. in that i ll get all datas from input file as string and store that as a string datatype in the postgres output also.
now i need to convert some of the datas to Integer type.. at which position i need to change the datatype.. and which is the component  to be used to do that....
7 REPLIES
Four Stars

Re: How to convert String To integer?

You have already used a component for converting data types i.e. tConvertType... besides this component, you can simply use tJavaRow and make use of java functions like Parse to convert string to integer data types
context.variable = Integer.parseInt("1234");

Thanks
Vaibhav
Moderator

Re: How to convert String To integer?

Hi,
There is a tConvertType component in your job design. How did you set it? Why didn't you use it to convert String to Integer type then loading data into DB?
Could you please give us more info about your job situation?
Best regards
Sabrina
--
Don't forget to give kudos when a reply is helpful and click Accept the solution when you think you're good with it.
Seventeen Stars

Re: How to convert String To integer?

hi,
+1 for tConvertType Smiley Happy
you see graphicaly that you're converting type in your job. 
When it's in a blackbox like tmap or hard coding somewhere else it's more difficult to trace what you've done Smiley Wink
regards
laurent
One Star

Re: How to convert String To integer?

hi all ,
thanks for your replies.. i have used the tconverttype component for setting NULL to the empty values.. for that only i used tconverttype. eventhough i have checked Autocast option , But i don't know how to use this component to change the data type. please help me 
Moderator

Re: How to convert String To integer?

Hi,
Please see component reference TalendHelpCenter:tConvertType with related scenario.
Best regards
Sabrina
--
Don't forget to give kudos when a reply is helpful and click Accept the solution when you think you're good with it.
One Star

Re: How to convert String To integer?

Hi xdshi,
 Thanks for your Reply,But the Problem is i am having the data like ($0.00).. so i take this as string type in tfiledelimited schema,
then i used the tconverttype,checked the auto cast option. and in the schema of the tconverttype i changed the datatype to Decimal, because i am not having the dollar datatype .. then i passed to the postgres output.. when i run i get zero rows .. and the error is
null.
please help to sort out this
Four Stars

Re: How to convert String To integer?

Hi,
If currency data type is considered as string, then you will have to trim first char from the string and then convert it using tconverttype... else results are wrong.. Use stringhandling.Right(stringhandling.Length(yourrow.column)-1)
Vaibhav