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

Announcements
Join us in Bucharest on Sept 18th for Qlik's AI Reality Tour! Register Now
cancel
Showing results for 
Search instead for 
Did you mean: 
_AnonymousUser
Specialist III
Specialist III

String to int conversion

Hello,
I am trying to convert a String into an int. I am using the expression:
Integer.parseInt(Name.SECURITY_LEVEL)
What I get when I test the expression is:
Exception in component tRowGenerator_1
and
Multiple markers at this line
- Syntax error on token ")", AssignmentOperator expected after
this token
- The left-hand side of an assignment must be a variable
I don't understand. Doesn't this expression return an int?
Thanks for any help,
Jim Long
Labels (2)
10 Replies
Anonymous
Not applicable

Hi Jim,
where did you entered that code? In a tMap?
Bye
Volker
_AnonymousUser
Specialist III
Specialist III
Author

Hello Volker,
Yes, this is in a tMap. Name.SECURITY_LEVEL is a number String (i.e. "1", "3", "9"). The new schema has an integer for this field. The transformation is simple, yet I am mystified by the error message I am getting.
Thanks,
Jim
_AnonymousUser
Specialist III
Specialist III
Author

Hello Volker,
I opened my project again and looked at the tMap. I am getting a new error message now. My expression is:
Integer.parseInt(Name.SECURITY_LEVEL)
The message I am getting is:
This method must return a result of type int.
parseInt is a public static int.
Thanks,
Jim Long
Anonymous
Not applicable

Hi,
I can see you have this error "Exception in component tRowGenerator_1" so the error might be even before the tMap component.
You're right, this method returns an Integer. The tmap should look like this.
_AnonymousUser
Specialist III
Specialist III
Author

Hello Volker,
....hmmm.
This is the transformation I have entered. I will pull the data out into a tLogRow to see what is coming out of the ODBC data source. I will let you know what I discover.
Thanks,
Jim Long
_AnonymousUser
Specialist III
Specialist III
Author

Hello Volker,
I pulled the data into into a tLogRow and I am getting the same result. However, even through the expression builder reports an error, the function seems to convert the String to an Integer just fine.
Let me know if you learn anything else.
Thanks,
Jim Long
Anonymous
Not applicable

Hi Jim,
a) you code looks correct.
b) the example of nhaumont too. So if you use it the same way it should work.
If the error still exists, please give us the following two information:
- The generated code around the error. You'll have a line number where the error occurs, switch to the code view and copy some line berore and after this line number.
- Give us a screen shot of the actual component where it happens. Search the code upwards to next comment to see the component name
Bye
Volker Brehm
Anonymous
Not applicable

Hello,
as nhaumont suggested, your error is not in the tMap but in the tRowGenerator_1.
Can you post a screenshot of it.
regards,
benjamin
Anonymous
Not applicable

Hi benjamin, hi nhaumont,
I think the message "Exception in component tRowGenerator_1" is related to the created class in the code (not the component). So it should happen in every component and to take a look into the code is the only way to be sure.
Bye
Volker