Hi everyone,
I have slightly rewritten our documentation. The phrase in question now reads as follows: “This command can be used to run several commands in a row, with no other transaction intervening the execution.”.
As Dirk has already indicated, XQuery is the way to go if you want to have atomicity.
I also thought about Dirk’s idea to simplify RUN. The problem might be that the input of EXECUTE would get ambiguous, provided that we don’t want to lose the possibility of specifying files. Moreover, the behavior of existing code could change. My initial idea of the discussed commands was:
1. XQUERY: execute queries 2. EXECUTE: execute command scripts 3. RUN: evaluate file from disk
Regarding the EXECUTE command, it could surely have been named better; with 8.5, in analogy with the XQUERY command, I may rename it to SCRIPT or COMMANDS.
Cheers, Christian
On Thu, May 19, 2016 at 8:11 PM, Wang, Genneva genneva.wang@sap.com wrote:
Hi
I’m trying to figure out whether batched transaction would work for basex, and I came across the RUN and EXECUTE command specified in http://files.basex.org/releases/8.4/BaseX84.pdf page 58-59. The document mentioned following in the summary section:
RUN:Evaluates the contents of file as XQuery expression. If the file ends with the suffix .bxs, the file content will be evaluated as command script. This command can be used to run several commands in a single transaction EXECUTE: Evaluates the specified input as command script. This command can be used to run several commands in a single transaction.
I’ve tried this myself For example, I’d like to know if I batch 2 inserts, if one fails, would both inserts get rollback.
I’m using a simple .bxs (attached and also listed below for your convenience) and run the execute using GUI.
OPEN test ADD TO embedded7.xml <root>embedded</root> ADD TO embedded8.xml <root>embedded CLOSE
The second ADD (embedded8.xml) is not a valid xml format so I’m expecting it to fail, and rollback both files if any of them have already added. But after executing this script, I’m seeing embedded7.xml have been added.
Would you be able to confirm if this is the expected behavior ? If so, is there anyway that I can batch multiple inserts and ensures that these batch of files can be committed at the same time, and rollback all together if any of the file has an error ?
Thank you very much for your help.