On 03/18/2008 02:43 PM, Keulen, M. van (Maurice) wrote with possible
deletions:
> Hi,
>
> I know that the XQUF prohibits it, but for writing robust functions, it
> is often necessary to mix query and update/docmgmt functionality. Some
> examples:
Hi Maurice,
I don't think what you suggest is necessary. If you want to query with
side effects -- which is certainly not what XQuery was initially
introduced for -- and you want to simulate XQueryP then you can *always*
use updating queries and return your results in a special result document.
>
> * Expression that queries/updates document, but if the document does
> not exist, adds an empty version of it:
> let $name := "foo.xml"
> let $emptydoc := <root/>
> let $doc := if (empty(pf:documents()[.=$name])) then
> (put($emptydoc,$name),$emptydoc) else doc("foo.xml")
> return $doc//bar
Here you expect, that the document management stuff is done just in time
and thus with side effects! Your query fails if the document management
stuff is done after the query part.
> * Expression that adds to a log-file:
> let $log := doc("log.xml")
> let $expr := ...some expression...
> return (do insert <entry>...{$expr}...<entry> as last into $log,$expr)
You can also return a ``nested'' sequence and query the result to split
up your query result and the log files. In my eyes you once more try to
``cheat'' to have more than a single result stream.
Jan
--
Jan Rittinger
Database Systems
Technische Universität München (Germany)
http://www-db.in.tum.de/~rittinge/
-------------------------------------------------------------------------
This SF.net email is sponsored by: Microsoft
Defy all challenges. Microsoft(R) Visual Studio 2008.
http://clk.atdmt.com/MRT/go/vse0120000070mrt/direct/01/
_______________________________________________
Monetdb-developers mailing list
[email protected]
https://lists.sourceforge.net/lists/listinfo/monetdb-developers