[MarkLogic Dev General] question about discrete transactions

Danny Sokolsky Danny.Sokolsky at marklogic.com
Fri Aug 13 10:03:55 PDT 2010


Another thing you could do is create a CPF pipeline with pipeline steps for each of your 3 actions.  Then CPF would manage that they all got created as expected, and catch up where it left off if something failed.

Another approach would be to have a semi-colon separated main module, where each statement would be its own transaction.

But what you are doing seems like it should work, and is appropriate if you need a document created (or some other transaction to occur) as part of a function.

-Danny

-----Original Message-----
From: general-bounces at developer.marklogic.com [mailto:general-bounces at developer.marklogic.com] On Behalf Of Jakob Fix
Sent: Friday, August 13, 2010 9:46 AM
To: General Mark Logic Developer Discussion
Subject: [MarkLogic Dev General] question about discrete transactions

Hi,

I've created an xquery module called by a document-creation trigger
that does the following:

1) copy the original document to another directory
2) remove the original document
3) add a property to the new document

In order for this to work, I created a function for each task, and
inside each function I did an xdmp:eval()  to make sure that these
actions are considered independent transactions. Can someone confirm
that this is the right approach? Judging from the documentation and
the fact that it works this seems ok, but I'm kind of hesitant to use
eval() all over the place.

Thanks,
Jakob.

Here's an example for the xdmp:document-insert wrapper function:

declare function local:insert-document( $new-filename as xs:string,
$doc as document-node() ) as item()*
{
    xdmp:eval("
      xquery version '1.0-ml';
      declare variable $new-filename as xs:string external;
      declare variable $doc as document-node() external;
      xdmp:document-insert( $new-filename, $doc )
    ",
      (
        xs:QName("new-filename"), $new-filename,
        xs:QName("doc"), $doc
      )
    )
};
_______________________________________________
General mailing list
General at developer.marklogic.com
http://developer.marklogic.com/mailman/listinfo/general


More information about the General mailing list