It is also possible to delete a document via an XQuery update expression, but the key/tricky thing is to specify the document - not the root element. (Deleting the root element would leave an empty document hanging around, so you need to delete the document node.)
Tobia, to modify the update delete expression in your first posting so that it deletes documents, just add “/…” to the end of it. At the moment it attempts to delete the root element, but the expression should select the parent of the root - the document…
Please also see this posting for more information.
Tnx Trevor! i’m sorry…i’ve made an “overloaded” topic! So i try to add some ideas to this post! Well…your solution -of course- works! If i write:
declare namespace tf='http://namespaces.softwareag.com/tamino/TaminoFunction'
update for $i in input()/Author[AuthorName='xxxxx']
do delete $i/..
taking away the “where” expression i expected an error like “attempt to delete the root element” or “ino:id required” or something like this! But it seems to work well! I think depends from the “$i/…” expression that returns the document itself (as you wrote in the other topic)! My question is…is this query correct? or it works becouse i’ve few instance in my db?
Your query (as presented in the previous posting) is correct. The example “delete query” that I posted in the other thread was based upon Michelle’s original query, that is the only reason that the ino:id attribute was used.
In your case, the root element “Author” is selected (where AuthorName=‘xxxxx’), and then the parent of “Author” is deleted. The parent of author is the document, so the effect is that the document is deleted.
You could also drop the filter condition / where clause - [AuthorName=‘xxxxx’] - to delete all the Author documents, and this will remain a valid / working expression. If you get into a large number of documents, it is conceivable that attempting to delete all of them will take longer than the “maximum query duration” (or maximum transaction) setting on the database…
One last thing: you don’t need to declare the “tf” namespace in your query - that was only required for the tf:getInoId() function.