You are not logged in.
Announcement
Unanswered posts
|
Pages: 1

I need to compare global variable value with string value. And if condition JOB must be stopped.
I did this on TJavaRow:
System.out.println("My value " + globalMap.get("IsLocked")) ;
if (globalMap.get("IsLocked") == "N") {System.out.println("Then");}
else {throw new RuntimeException("----Raise error-------");};
Why condition doesn't work? It raises error while Println returns " My value N".
Global variable type is Char.
Offline
Hi,
Use the Java equals() function instead of the == operator for string comparisons.
( (String)globalMap.get("isLocked") ).equals("N")
Offline

Hi walkerca,
now code looks like:
System.out.println("My value " + globalMap.get("IsLocked")) ;
if (( (String)globalMap.get("IsLocked") ).equals("N")) {System.out.println("Then");}
//else {System.out.println("Then2");};
else {throw new RuntimeException("----Raise error-------");};
But i get error:
Exception in component tJavaRow_2
java.lang.ClassCastException: java.lang.Character cannot be cast to java.lang.String
When i remove (String) option it doesn't compares values in right way. I mean runs "---- Raise error ---" while value is "N" Println returns - My value N
I tried IsLocked in MSSQLInput Edit schema change DB type between CHAR and VARCHAR but it didn't help..
EDIT : need to change Type to String in Edit Schema.
Thanks.
Last edited by ataris (2011-05-05 08:09:43)
Offline
Was isLocked set with a 'N' rather than "N" (single versus double quotes)? Make sure that it was actually loaded in the globalMap as a String.
Offline
Pages: 1