I am trying to execute the xquery on Sedna database to conditionally update the container, as below
if(fn:exists(doc("blog")/entries/entry[@active="1" and @id="1"]/comments)) then
UPDATE insert <comment active="1"><name>sunil.s</name><email>suni.l.s@gmail.com</email><desc>desbbh</desc></comment> into doc("blog")/entries/entry[@active="1" and @id="1"]/comments
else
UPDATE insert <comments><comment active="1"><name>sunil.s</name><email>sunil.s@gmail.com</email><desc>sdd</desc></comment></comments> into doc("blog")/entries/entry[@active="1" and @id="1"]
But this query always failing with below error
SEDNA Message: ERROR XPST0003 It is a static error if an expression is not a valid instance of the grammar defined in A.1 EBNF. Details: at (2:8), syntax error, unexpected insert, expecting else
The error indicate that it is expecting else
instead of insert
in the second line.
Can someone please help me understand problem with the query and possible fix?