Aviator
Aviator

Reputation: 722

multiple statements in if condition in xquery

I am writing a function in xquery in which i want to return an if else statement. I am trying the following let's say :

return if (somevalue eq 1) then (some-method($var1, $var2,....), "RandomValue" else (do... this..)

What i want here is, i want the if condition to run and when somevalue is eq to 1 then it should first call the some-method() function and then append "randomvalue" after it.. {basically my code is building a sql statement). Although the above that i have tried is giving me error that "expecting else" but I think that i should be able to do multiple things inside the if statement (if whatever is there in the if condition is true then). So how can I achieve that?

Upvotes: 0

Views: 431

Answers (1)

Christian Grün
Christian Grün

Reputation: 6229

The query seems to be nearly complete. Multiple expressions can be wrapped in parentheses:

...
return if (somevalue eq 1) then (
  some-method($var1, $var2,....), "RandomValue"
) else (
  do... this..
)

Upvotes: 2

Related Questions