running several updating queries from a single query?
Tuesday, 10 June 2025 · 3 messages
GS
Graydon Saunders10 Jun 2025 16:03 #
Hello!
So if I have a number of updating queries, what's the best way to write a query that will run all of them in some fixed order? (I am doing this from the GUI.) All the individual updating queries do what they're expected to do and it works if I run them in sequence from the GUI, query one, query two, and so on. If I try to chain them together:
xs:anyURI('updating-query-1.xq') => xquery:eval-update(),
xs:anyURI('updating-query-2.xq') => xquery:eval-update()Seems to work OK for the first two or three and then to start having issues (in the sense that the updates don't appear to happen to the target) if I chain four or five together. (The updating queries get the db name to update from a common xquery module.)
It also looks inelegant, like there ought to be a better way.
Anyone got any suggestions? Or is this not a sensible thing to be attempting?
Thanks!
Graydon
CG
Christian Grün10 Jun 2025 16:16 #
Hi Graydon,
If you use a recent version of BaseX, I recommend you to have a look at
job:execute [1].Quoted text · Graydon Saunders · 2 lines
> xs:anyURI('updating-query-1.xq') => xquery:eval-update(), > xs:anyURI('updating-query-2.xq') => xquery:eval-update()
With xquery:update, all updates will end up on the same pending update list [2], which means that they will be executed at the very end of the evaluation of your query. See the link for more information on the general semantics of XQuery Update.
Hope this helps,
Christian
[1] https://docs.basex.org/12/Job_Functions#job:execute
[2] https://docs.basex.org/main/Updates#pending_update_list
Graydon Saunders <graydonish at fastmail.com> schrieb am Di., 10. Juni 2025, 16:03:
Quoted text · Graydon Saunders · 24 lines
> Hello! > > So if I have a number of updating queries, what's the best way to write a > query that will run all of them in some fixed order? (I am doing this from > the GUI.) All the individual updating queries do what they're expected to > do and it works if I run them in sequence from the GUI, query one, query > two, and so on. If I try to chain them together: > > xs:anyURI('updating-query-1.xq') => xquery:eval-update(), > xs:anyURI('updating-query-2.xq') => xquery:eval-update() > > Seems to work OK for the first two or three and then to start having > issues (in the sense that the updates don't appear to happen to the target) > if I chain four or five together. (The updating queries get the db name to > update from a common xquery module.) > > It also looks inelegant, like there ought to be a better way. > > Anyone got any suggestions? Or is this not a sensible thing to be > attempting? > > Thanks! > Graydon >
GS
Graydon Saunders10 Jun 2025 16:40 #
Hi Christian,
job:execute() is just what I needed; thank you!
With respect to xquery:update(), it looks like chaining queries works right up until two of them touch the same elements, which makes sense with respect to the pending update list. (I was unclear if the list was per-query or per-calling query, which is more than likely down to me being in too much of a hurry.)
Thanks!
GraydonQuoted text · Christian Grün · 35 lines
On Tue, Jun 10, 2025, at 10:16, Christian Grün wrote: > Hi Graydon, > > If you use a recent version of BaseX, I recommend you to have a look at job:execute [1]. > > > xs:anyURI('updating-query-1.xq') => xquery:eval-update(), > > xs:anyURI('updating-query-2.xq') => xquery:eval-update() > > With xquery:update, all updates will end up on the same pending update list [2], which means that they will be executed at the very end of the evaluation of your query. See the link for more information on the general semantics of XQuery Update. > > Hope this helps, > Christian > > [1] https://docs.basex.org/12/Job_Functions#job:execute > [2] https://docs.basex.org/main/Updates#pending_update_list > > > > Graydon Saunders <graydonish at fastmail.com> schrieb am Di., 10. Juni 2025, 16:03: >> __ >> Hello! >> >> So if I have a number of updating queries, what's the best way to write a query that will run all of them in some fixed order? (I am doing this from the GUI.) All the individual updating queries do what they're expected to do and it works if I run them in sequence from the GUI, query one, query two, and so on. If I try to chain them together: >> >> xs:anyURI('updating-query-1.xq') => xquery:eval-update(), >> xs:anyURI('updating-query-2.xq') => xquery:eval-update() >> >> Seems to work OK for the first two or three and then to start having issues (in the sense that the updates don't appear to happen to the target) if I chain four or five together. (The updating queries get the db name to update from a common xquery module.) >> >> It also looks inelegant, like there ought to be a better way. >> >> Anyone got any suggestions? Or is this not a sensible thing to be attempting? >> >> Thanks! >> Graydon
Written for BaseX 11.9. BaseX may have changed since: please check the current documentation.
⚡Generated with XQuery