You are not logged in.
I am trying to get a value resulted from a SQL query in global variable, but i have the error below:
Exception in component tMysqlInput_1
java.lang.ClassCastException: java.lang.String cannot be cast to java.lang.Integer
Below the components i used:
- tmysqlSP: executing stored procedure to load a specific table
- tmysqlinput (errotab): getting the number of rows in tthe table using a query with count(*) and storing this value in a global variable(cpt).
- tmsgbox: displaying a specific message depending the IF link condition
It seems that by definition Talend considers a global variable as a String, I tried the (Integer) cast but it gave me the error above.
Last edited by chesofai (2012-07-09 12:27:57)
No i didn't try it.
I am trying to workaround my issue by comparing Strings. But my new issue is that in my TMysqlinput, i have a query
like "select count(*) as value from errortable" and i want to get the value returned by the query in a global variable, but i don't know if it can work?
I created i variable called "cpt" having the value "value" (from sql query!), but it seems that the Global variable is not getting the value!!
How can i get the value of the SQL query ??
than you so much
i've changed the request by :
"SELECT count(*) as nbre FROM `id24945`"
and it work fine !
retrieve the job (item) if you like on my github
Last edited by kzone (2012-07-09 23:12:33)
thank you Kzone,
I am using TOS 5.0.2, tried to import your talend job and it failed.
then downloaded TOS 5.1, tried to import again the talend job, but it didn't work.
could you help please? or send me the snashot for all the components especially , the tsetglobalvar and the IF !!
I have import item in 5.1.1 and works fine
use the right button to do it ...
nerver mind see screenshoot
about if , what is the condition to display message?
Sorry for the delay in answering you, i was sick these days.
I did as you showed and it worked, using the IF condition comparing the strings:
!((String)(globalMap.get("cpt"))).equals("0") where "cpt" is the global variable resulting from the select query.
My aim was to compare the "cpt" to 0, but i am always having an error saying that cannot convert value, so i decied to
Do you have an idea to make the IF condition comparing the integer values instead of strings ??? ( i already tried to cast the condition using (Integer).