Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

XQuery - Variables in function definition

Tags:

xquery

Is it possible to declare a variable to be used only inside of function declaration? If so - how to do it?

like image 391
Cleankod Avatar asked Mar 27 '26 00:03

Cleankod


1 Answers

Variable declaration can only be placed in the prolog of a query, but you can wrap your function code with a FLWOR expression, consisting of a single LET and RETURN clause. An example:

declare function local:func() {
   let $var := ...your variable...
   return
      ...your actual code...
};

Hope this helps, Christian

like image 67
Christian Grün Avatar answered Apr 02 '26 09:04

Christian Grün



Donate For Us

If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!