Subject:problem with Conditional Expressions Author:Karen Lopez Date:30 Apr 2010 11:58 AM
Hi, I'm learning Xquery and I have some troubles to do the follow!
let $a := "1"
let $b := "2"
return
if ($a = "1")
then(
let $string := concat($a, "Some")
)
else()
if ($b = "2")
then(
let $string := concat($b, "Any")
)
else()
I need to validate the two variables with the two IFs and I canīt use ELSE IF because It isnot the same... How I can use various conditionals in a only return statement... thank you so much...
Hi Karen,
in XQuery variables are immutable once they have been assigned. Could you explain what you are trying to achieve, so that we can suggest the correct approach?
Hi Karen,
I hope my Spanish is good enough to understand the question...
If you want to concatenate several strings, it's just enough to do a long
concat($varExpression, $param1, $param2, $param3)
If they are empty, it's just like you didn't specify them as part of the concatenation.
In case you want to test for special values, you can add if() statements around the arguments, like in
concat($varExpression, if($param1!="xxx") then $param1 else (), if($param2!="xxx") then $param2 else (), if($param3!="xxx") then $param3 else ())