XQuery variable declaration

View: New views
1 Messages — Rating Filter:   Alert me  

XQuery variable declaration

by Marko Bozikovic-2 :: Rate this Message:

Reply (Restricted by the Administrator) | Reply to Author | View Threaded | Show Only this Message

Hi all,

I'm quite new to XQuery and I have a question about XQuery variable
declaration and function execution...

I have a test query that looks something like this:

declare function local:foo($year as xs:string)
{
 (: do something :)
};

declare variable $year := '2005';
declare variable $u := local:foo($year);

<foo>
{$u}
</foo>

This query takes 7-8 seconds to execute.

When I change the query to:

declare function local:foo($year as xs:string)
{
 (: do something :)
};

declare variable $year := '2005';

<foo>
{
let $u := local:getUgovori($year)

return $u

}
</foo>

It's executed in less than half a second. Why?

General problem that I have is that I need some kind of 'global' variable to
hold a result from a function and use it to build something like this:

declare variable $year := '2005';
declare variable $foo := local:foo($year);

<foo>
{
for $i in local:foo2()

   let %j := local:foo3($i, $foo)
   return
   <row>
      $j
   </row>
}
   <row>$foo</row>
</foo>


TIA,
--
Marko Božiković
Tellus d.o.o.
Tel.  +385 1 3691 975
Fax   +385 1 3691 976
E-Mail:  marko.bozikovic@...
Ogrizovićeva 40a
10000 Zagreb
Hrvatska


------------------------------------------
To remove yourself from this list, send an
email to xml-unsubscribe@...