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

Announcements
See why IDC MarketScape names Qlik a 2025 Leader! Read more
cancel
Showing results for 
Search instead for 
Did you mean: 
Anonymous
Not applicable

tSetGlobalVar var type

Hi,
Im trying to set a GlobalVar to a value like "99999999999999", but i got the following error: Exception in thread "main" java.lang.Error: Unresolved compilation problem: The literal 99999999999999 of type int is out of range.
How can I set this variable type to "Long"?
Labels (3)
5 Replies
Anonymous
Not applicable
Author

Hello,
if that do no problem put " on the value "99999999999999" and use them as string.
After cast the global variable.
Else use a tJava with (Integer)globalMap.put("myKey","value")
else change type to float

Best regards
Jeremie
Anonymous
Not applicable
Author

Thanks jeremie, but now I got the following error: Exception in component tMap_4. java.lang.ClassCastException: java.lang.String cannot be cast to java.lang.Long.
In truth I want to use the time of today in this variable, to compare with some files time... any other ideas?
Anonymous
Not applicable
Author

Ok,
i think you compare two objects with diferent type or the type output is diferent of the type of the expression.
to cast use expression like Long.valueOf(row.RefFieldEnter).
Jeremie
Anonymous
Not applicable
Author

Thanks,
I already managed to do it by using a TalendDate.GetCurrentDate.GetTime. It seens like this expression returns a long, the variable is automatically set to this type.
Anonymous
Not applicable
Author

Hello,
if that do no problem put " on the value "99999999999999" and use them as string.
After cast the global variable.
Else use a tJava with (Integer)globalMap.put("myKey","value")
else change type to float
Best regards
Jeremie

Seriously?!
Can't the tSetGlobalVar set long variables?
I have a similar problem where I want to put a long value, which I fetch through a query, into a global var with tSetGlobalVar.
Do I then need to write this in as code in tJava-component?