Skip to content

Instantly share code, notes, and snippets.

@ableasdale
Created December 11, 2020 12:19
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save ableasdale/569a4e1fbf54c85a510ccedf9437d9c5 to your computer and use it in GitHub Desktop.
Save ableasdale/569a4e1fbf54c85a510ccedf9437d9c5 to your computer and use it in GitHub Desktop.
MarkLogic: Delete one document after inspecting both duplicates in the event of an XDMP-DBDUPURI
xquery version "1.0-ml";
(:
A Utility module to allow the deletion of a fragment in a given forest in the event of
an XDMP-DBDUPURI exception.
Given the following exception:
XDMP-DBDUPURI: URI /problem/uri.xml found in forests Library06 and Library07
$doc would be set to "/problem/uri.xml"
$forest-name would be set to either "Library06" or "Library07" on inspecting the document in both forests.
:)
let $doc := "/" (: URI for the document that is found in 2 forests :)
let $forest-name := "forest_00" (: The name of the forest from which the document should be removed :)
let $query :=
'xquery version "1.0-ml";
declare variable $URI as xs:string external;
xdmp:document-delete($URI)'
let $options := <options xmlns="xdmp:eval"><database>{xdmp:forest($forest-name)}</database></options>
return xdmp:eval($query,(xs:QName("URI"),$doc),$options)
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment