Reputation: 55
I am new to xquery and have a hard time finding more than just the basics online. I have existing code I want to change but I don't know how to include multiple function calls or variable assignments in a single if-then statement.
Say I have this block
if (fn:namespace-uri(.) = 'http://xmlns.oracle.com/communications/sce/dictionary/testNamespace'
and //tns:CreateSalesOrder/tns:ListOfSWIOrderIO/tns:SWIOrder/tns:OrderTypeCode/text() = 'Test Order'
and $isDefaultVersion)
then true()
else false()
How can I include a function call after true()?
Something like this but I dont know the exact syntax:
if (fn:namespace-uri(.) = 'http://xmlns.oracle.com/communications/sce/dictionary/testNamespace'
and //tns:CreateSalesOrder/tns:ListOfSWIOrderIO/tns:SWIOrder/tns:OrderTypeCode/text() = 'Test Order'
and $isDefaultVersion)
then true(), util:write-record('123','johndoe')
else false()
Upvotes: 0
Views: 142
Reputation: 163458
You can write:
if (...) then (true(), util:write-record('123','johndoe')) else ...
Note the parentheses.
I suspect from the name that util:write-record()
is a function that has side-effects. Functions with side-effects are very tricky in XQuery and you need to understand how they are handled by your particular implementation. There is always a risk that the query optimizer will change the order of evaluation so side-effects happen in an unexpected order, or that particular calls will not happen at all because the optimizer decides the result is not needed.
Upvotes: 1