Hello Kristian, thanks for the pointer! The documentation is certainly misleading, I agree. However, it is not wrong and I think the issue here is that RUN can be used for two completely separate things: run an xquery file (where it is indeed a single transaction, so the comment is appropriate) and run a basex command script.
I personally would remove the second functionality (run a basex command script) from the RUN command and instead include the functionality in the already existing EXECUTE function. That way it would be clear: Use RUN for xquery files, use EXECUTE for bxs. I will discuss this with Christian Grün when he's back. Cheers Dirk On 05/20/2016 09:41 AM, Kristian Kankainen wrote: > Maybe it would be wise to change the documentation or specify what > exactly is meant by the phrase "This command can be used to run > several commands in a single transaction". Clearly it can be > understood in a wrong way. > > Cheers > Kristian > > 20.05.2016 09:59 Dirk Kirsten kirjutas: >> >> Hello Genneva, >> >> this is expected behaviour. BaseX script executed each command >> separately. This is by design and required by the nature of XQuery >> (Update), which by design always executes as one transaction - Which >> can be difficult do deal with if you have a large amount of data and >> have to e.g. hold it in memory. >> >> Each XQuery runs in one single transaction, so you can simply add >> your documents via XQuery, e.g. >> >> db:add("DB", "embedded7.xml"), >> db:add("DB", "embedded8.xml") >> >> Cheers >> >> Dirk >> >> >> On 05/19/2016 08:11 PM, Wang, Genneva 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. >> >> -- >> Dirk Kirsten, BaseX GmbH, http://basexgmbh.de >> |-- Firmensitz: Blarerstrasse 56, 78462 Konstanz >> |-- Registergericht Freiburg, HRB: 708285, Geschäftsführer: >> | Dr. Christian Grün, Dr. Alexander Holupirek, Michael Seiferle >> `-- Phone: 0049 7531 91 68 276, Fax: 0049 7531 20 05 22 > -- Dirk Kirsten, BaseX GmbH, http://basexgmbh.de |-- Firmensitz: Blarerstrasse 56, 78462 Konstanz |-- Registergericht Freiburg, HRB: 708285, Geschäftsführer: | Dr. Christian Grün, Dr. Alexander Holupirek, Michael Seiferle `-- Phone: 0049 7531 91 68 276, Fax: 0049 7531 20 05 22