===Pending Update List===
The most important thing to keep in mind when using XQuery Update is the Pending Update List (PUL). Updating statements are not executed immediately, but are first collected as update primitives within a set-like structure. At the end of a query, after some consistency checks and optimizations, the update primitives will be applied in the following order:
db:optimize()
db:flush()
db:drop()
db:create()
</pre>
It may be surprising to see [[Database Module|db:create]] on the bottom of this list.
If an inconsistency is found, an error message is returned and all accessed databases remain untouched (atomicity). For the user, this means that updates are only visible '''after''' the end of a snapshot.
====Example====
The query…