Hi again, Soumadri!

At 2009-12-05 18:49 +0530, Chowdhury, Soumadri wrote:
I have written two consecutive FLOWR expressions like the following,

let $a1 := "" return (xdmp:document-insert("/demo010",<a>data</a>)),
let $a2 := "" return (fn:doc("/demo010"))

The problem is the 2nd line returns an empty sequence, instead of the content of the uri "/demo010"

How to resolve this problem? Any idea?

I learned the answer recently: it has to do with database transactions. Certain database transactions are not committed to the database until the query is complete.

As a test I formally declared the module to be using the Mark Logic version of the language:

xquery version "1.0-ml";
let $a1 := "" return (xdmp:document-insert("/demo010",<a>data</a>)),
let $a2 := "" return (fn:doc("/demo010"))

... which didn't work as yours didn't work and then changed it to:

xquery version "1.0-ml";
let $a1 := "" return (xdmp:document-insert("/demo010",<a>data</a>));
let $a2 := "" return (fn:doc("/demo010"))

... which worked fine. Note the change of the comma to a semi-colon at the end of the first assignment.

This is using the Mark Logic extension to XQuery of ending a query with a semi-colon which allows one to put multiple queries in a single document. The first query ends at the semi-colon and the database does its business of committing all of the changes. The second query is then acting on a complete database with your more recent addition and finds it.

Since we are now dealing with complete queries instead of portions of a FLWOR expression, your test can be rewritten as follows:

xquery version "1.0-ml";
xdmp:document-insert("/demo010",<a>data</a>);
fn:doc("/demo010")

I haven't yet learned *when* queries need to be flushed/committed to the database, and I hope someone on the list can give general guidelines ... but this is how I recently resolved a related Mark Logic database issue.

Perhaps is there a formal request one can make in a query to commit any uncommitted transactions?

I hope this helps.

. . . . . . . . . . . . Ken

--
XSLT/XQuery/XPath training after http://XMLPrague.cz 2010-03-15/19
Vote for your XML training:   http://www.CraneSoftwrights.com/q/i/
Crane Softwrights Ltd.          http://www.CraneSoftwrights.com/q/
Training tools: Comprehensive interactive XSLT/XPath 1.0/2.0 video
Video lesson:    http://www.youtube.com/watch?v=PrNjJCh7Ppg&fmt=18
Video overview:  http://www.youtube.com/watch?v=VTiodiij6gE&fmt=18
G. Ken Holman                 mailto:[email protected]
Male Cancer Awareness Nov'07  http://www.CraneSoftwrights.com/q/bc
Legal business disclaimers:  http://www.CraneSoftwrights.com/legal

_______________________________________________
General mailing list
[email protected]
http://xqzone.com/mailman/listinfo/general

Reply via email to