Unlock a world of possibilities! Login now and discover the exclusive benefits awaiting you.
Hi,
I'm having difficulty with If/Then expressions using two variables in tMap:
This example works:
when varTemp = "BBB" then "X" is output otherwise vartemp is output
vartemp = row1.MultiValue.split(";")[1]
varSingleValue2 = Var.vartemp.equals("BBB")?"X":Var.vartemp
This example doesn't, but the logic is the same:
vartemp = row1.MultiValue.split(";")[1]
varSingleValue2 = if (Var.vartemp == "BBB") {
"X";
} else {
Var.vartemp ;
}
When I run the job I get the error:
Syntax error, insert "VariableDeclarators" to complete LocalVariableDeclaration
Could you explain where I am going wrong?
Many thanks,
Bob.
in Tmap expression multi-line expression will not work.
in Tjava/Tjavarow/flex
if (Var.vartemp.equals("BBB")) {
SingleValue2 = "X";
} else {
SingleValue2 = Var.vartemp ;
}
in Tmap expression multi-line expression will not work.
in Tjava/Tjavarow/flex
if (Var.vartemp.equals("BBB")) {
SingleValue2 = "X";
} else {
SingleValue2 = Var.vartemp ;
}
Ok, many thanks.
Bob.
You cannot have an "if" expression on the right side of an assignment.
That's the reason why the 1rst example works (using ternary operator) and the 2nd one doesn't.
Also, you should never use "==" to compare 2 strings, String.equals() and equalsIgnoreCase() methods are here for that.
Ah, we've tried this one! And it helped, actually. But anyway, we had to think through all levels of development and maintenance... and few weeks ago we've asked ourselves how much does it cost to build a website, and we hired the separate dev team, so they started building mobile-friendly website from scratch. Of course, you can try to build an app by yourself. But would it be reliable enough?