[MarkLogic Dev General] How to display updated document right after update query

Dave Cassel Dave.Cassel at marklogic.com
Fri Mar 27 10:40:57 PDT 2015


The semicolon works in a main module. If you need to do the same in a library module, use xdmp:eval() and do the update in a different transaction. More info in the Application Developer's Guide: http://docs.marklogic.com/guide/app-dev/transactions#id_24388

--
Dave Cassel
Developer Community Manager
MarkLogic Corporation<http://www.marklogic.com/>
MarkLogic World - San Francisco April 13 - 17<http://world.marklogic.com/locations/san-francisco/>


From: Sudheer Yalaverthi <sudheer.yalaverthi at db.com<mailto:sudheer.yalaverthi at db.com>>
Reply-To: MarkLogic Developer Discussion <general at developer.marklogic.com<mailto:general at developer.marklogic.com>>
Date: Friday, March 27, 2015 at 12:02 PM
To: MarkLogic Developer Discussion <general at developer.marklogic.com<mailto:general at developer.marklogic.com>>
Subject: Re: [MarkLogic Dev General] How to display updated document right after update query


Classification: Public
Hi Danny,


You can end the transaction with semi colon. Then in the same x-query, access the document and return it.

For ex.

(: This is the first transaction where update happens:)
declare variable $uri as xs:string := "/doc/sample.xml";
let $doc := fn:doc($uri)
return xdmp:node-replace($doc/update-node, element new-node { "new text"})
;

(:This is the second transaction where you can read the changes from first transaction :)
(: Variables, imports, namespaces must be defined again here.:)

declare variable $uri as xs:string := "/doc/sample.xml";

fn:doc($uri)




From: general-bounces at developer.marklogic.com<mailto:general-bounces at developer.marklogic.com> [mailto:general-bounces at developer.marklogic.com] On Behalf Of Danny Sinang
Sent: Friday, March 27, 2015 11:54 AM
To: general
Subject: [MarkLogic Dev General] How to display updated document right after update query

I've an update query that replaces a node within a document.

The node replacement works, but the requirement is for the same query to return the contents of the updated document.

I know this isn't normally possible since the update query doesn't do a commit till after the query is executed.

Anybody know of a workaround for this ?

Regards,
Danny



---
This communication may contain confidential and/or privileged information. If you are not the intended recipient (or have received this communication in error) please notify the sender immediately and destroy this communication. Any unauthorized copying, disclosure or distribution of the material in this communication is strictly forbidden.

Deutsche Bank does not render legal or tax advice, and the information contained in this communication should not be regarded as such.
-------------- next part --------------
An HTML attachment was scrubbed...
URL: http://developer.marklogic.com/pipermail/general/attachments/20150327/dbe129bd/attachment-0001.html 


More information about the General mailing list