Which version of the server are you using?

You haven't said what's going wrong. What's the problem? If you have an error 
message it's always a good idea to paste that in.

I suspect that you're seeing something like "XDMP-MULTIDBSTMT: Cannot process 
different-database requests with same-statement isolation". If so the error 
message says it all: you can't update two different databases in the same 
statement. This is covered at 
http://docs.marklogic.com/guide/app-dev/transactions#id_24388

> You may not use same-statement isolation when using the database option of 
> xdmp:eval orxdmp:invoke to specify a different database than the database in 
> the calling statement's context. If your eval/invoke code needs to use a 
> different database, use different-transaction isolation.

Using different-transaction isolation means that you're really committing two 
transactions, each atomic in its own database but discrete from each other. You 
can try to structure your update sequence so that the first update will be the 
sensitive one, and will automatically keep the second one from running if it 
throws an error. But I can't think of a way to update two different databases 
in a single ACID transaction. I don't think multi-statement transactions will 
help. You could try XA, I suppose, but that gets complicated quite quickly and 
I wouldn't recommend it.

At this point I would back up and revisit the design. Why do you want to update 
two databases at once? If two documents need to participate in a transaction, 
maybe they should be in the same database. Then you wouldn't need any invokes 
at all.

In passing, the xdmp:quote($input) is probably unnecessary. I imagine you added 
that in an attempt to work around XDMP-MULTIDBSTMT, but it won't.

-- Mike

On 25 Feb 2013, at 07:50 , Jonna Marry <[email protected]> wrote:

> Hi,
> 
> I have a scenario to insert 2 different documents in 2 different databases in 
> single transaction.If either one fails, I need to roll back the insert 
> operation.
> I tried using "xdmp:transaction-mode" and 
> "<isolation>same-statement</isolation>   " options. It would be helpful if I 
> get some suggestion to resolve this issue.
> 
> 
> xquery version "1.0-ml";
> declare option xdmp:transaction-mode "update";
> 
>  let $_1 := xdmp:invoke( ("/aa.xqy")), 
>                                         (
>                                             xs:QName("input"), 
> xdmp:quote($input),
>                                           
>                                         ),
>                                         <options xmlns="xdmp:eval">           
>                                                                               
>  
>                                            
> <isolation>same-statement</isolation>  
>                                   
> <database>{xdmp:database("test1")}</database>                   
>                                          </options>
>                                         )
> let $_2 := xdmp:invoke( ("/aa.xqy")), 
>                                         (
>                                             xs:QName("input"), 
> xdmp:quote($input),
>                                           
>                                         ),
>                                         <options xmlns="xdmp:eval">           
>                                                                               
>  
>                                            
> <isolation>same-statement</isolation>   
>                                           
> <database>{xdmp:database("test2")}</database>                 
>                                          </options>
>                                         )
> return "success"
> note :
> 
> Regards,
> Jonna.
> _______________________________________________
> General mailing list
> [email protected]
> http://developer.marklogic.com/mailman/listinfo/general

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

Reply via email to