Hi Ramzi, 

I am not sure whether your are using RestXQ, however if you do, the implementation should take care of this by itself.

XQuery update in general either applies the whole updating query, or cancels all updates:

Take the following example db containing 5 documents.

db:create("mailinglist",
  (1 to 5) ! <foo doc="{.}"/>,
  (1 to 5) ! ("doc-"|| . ||".xml")
)

Now if you ran an update: 
for $i in 1 to 5
let $x := if($i > 4) then error() else ()
return (
  prof:dump($i, "Inserting "),
  insert node element _ {
   "Hello World"
  } as last into db:open("mailinglist
", "doc-"||$i||".xml")
)

You can see in the GUI / Debug View, that the code for inserting the elements in the first 4 Documents is executed, and thus the pending update list is populated in memory. 

Once the Query throws the error() the whole query is cancelled and the pending update list is discarded.

Hence no changes are applied to your databases, if you manage to handle the whole update in a single transaction.

Feel free to ask for more information!

Best
Michael
 
Am 06.07.2020 um 08:38 schrieb Ramzi Hammouda <Ramzi.Hammouda@se.linedata.com>:

Hello BaseX team,
We're developing an application where a command can result in saving data on multiple xml documents in the same database. We're using Rest APIs. Now, We're looking on handling saving errors. For example, if there were an error in saving data on a one document, then the saving of data on other documents must be canceled (even if there were successful updates, they must be canceled). How can this be implemented?
 
Thanks.
 

P
 Respectons ensemble l'environnement. N'imprimez ce message que si nĂ©cessaire. Let's respect the environment together. Only print this message if necessary.