Why do I see return() at the end of an XQuery query?
e.g.
let $updateIssues:=
for $issue in fn:collection("InProgress_Audit")/ProductIssue
return local:UpdateIssue($issue)
return ()
It's not entirely clear what your question is. Given the way you've formulated it, possible answers include:
Perhaps you mean 'why is it there?' Possible answers include:
return clause the FLWOR expression begun by the let clause is not complete.()).return keyword in XQuery can be written to look like a function call. (The author may enjoy hazing newbies and practical jokes, too; approach with caution.) Perhaps you mean "what does this query mean and how does it mean it?" Possible answers include:
updateIssues (whose value is given by a nested FLWOR expression), and then returns () (that is, the empty sequence). Since nothing in the return clause depends on the value of updateIssues, there is no need for an XQuery engine to evaluate the expression used to specify the value (but there is also no guarantee that it won't do so -- processors are allowed to be smart about optimization but not required to be).In your example, the return () expression is the body of your let expression.
The assignment to $updateIssues is walking through a bunch of nodes, returning the value from a call to local:UpdateIssue(), and the sequence of those return values is being used as the variable value.
But, then, nothing is done with the variable and the function simply returns nothing to its caller.
I would be worried that an optimizing processor may choose to throw out the assignment because the variable being assigned isn't being used anywhere, but the processor you are using is likely not doing that if you are getting the update results you are expecting.
So, all that last line is doing is always returning an empty sequence as the value of the function when called.
If I get your question right you are asking about return ().
return () means that you are returning a blank so in short you just want to assign the global variable to something and do not want to return anything from the function.
Else if you want to know the details on Return expression. It is a Part of XQuery FLWOR Expressions.
Being a functional language XQuery works on Functions.
For Loop, Let Loop, Where, Order By (FLWO) are all internally (inside XQuery Engine) acting as functions. Thus they all require a return after call to specify what needs to be the output from them.
If you require more information on XQuery functions you may refer the offical documentation.