Reputation: 7654
I'm trying to create a xquery expressions that inserts some new nodes only if a condition is true and returns an error if the condition is false. A simplyfied version of my state is:
let $a := [...]
return
if($a/@something != "true") then (
insert node (
element {'Foobar'} { }
) into $a/somenode
) else (
)
My problem: whenever if put something like <Error/>
into the else i get an error "[XUST0001] No updating expression allowed in this context".
/e: Okay...if I understand this correctly i can't have updateing expressions AND a return value....so I have to find another way.
Upvotes: 1
Views: 1298
Reputation: 958
You can use fn:error() to raise the error, or use () to do nothing. Unfortunately XQuery Update doesn't allow you to do what you want - maybe it will be fixed in a future version.
Upvotes: 3