Loading TOC...


   $sparql as String,
   [$bindings as Object?],
   [$options as String[]],
   [$store as sem.store[]],
   [$default-permissions as Object[]]
) as null


Executes a SPARQL Update operation against the database.

Graph Update - addition and removal of triples from some graphs within the Graph Store.

Graph Management - creating and deletion of graphs within the Graph Store, as well as convenient shortcuts for graph update operations often used during graph management (to add, move, and copy graphs).

This function is a built-in.

$sparql The SPARQL Update to be executed.
$bindings A map containing initial values for variables from the query, or the empty sequence if no query variables are to be initially bound. This is a way to parameterize the query.
$options Options as a sequence of string values. Available options are:
The initial base IRI for the query.
Add the named graph or graphs specified by the IRI to the default graph for the query.
Add the named graph or graphs specified by the IRI to the list of named graphs available in the query.
Parse the query, but don't perform static checks or execute it.
Parse and optimize the query, caching the result. No execution is performed.
Sets the optimization level to use. Levels of 0 (off), 1, and 2 are recognized, with 1 as the default.
Sets de-duplication of triples results to "on" or "off". The default, standards-compliant behavior is "on".
Sets The database directory path of triples document. Default location is /triplestore.
The number of triples in a triples document. Default is 100.
Update fails if the specified destination graph does not already exist.
ISOLATION_LEVEL can be different-transaction or same-statement. Default is different-transaction, which will not change the transaction mode of the calling transaction. If isolation is same-statement, the calling transaction should be run in update mode and the $sparql cannot contain multiple statements.
TXN_ID is the transaction ID which the SPARQL program is in. Setting transaction-id implies isolation to be different-transaction. Transaction-id cannot coexist with isolation same-statement.
$store A sem:store constructor to use as the source of the triples for SPARQL Update. If multiple sem:store constructors are supplied, the triples from all the sources are merged and queried together. The default for sem:store the current database's triple index. The locking option specified in sem:store will be used by sem:sparql-update.

If a sem:store value is not supplied, then the default sem:store for the statement will be used. This is the same as calling sem:store() with all arguments omitted, which will access the current database's triple index, using the default rulesets configured for that database. The default for locking is read-write.

Note: You cannot use an in-memory store with SPARQL Update.

$default-permissions Security permission objects corresponding to the permissions for the graph during graph creation. If not supplied, the current user's default permissions are applied. The default value used for this parameter can be obtained by calling xdmp.defaultPermissions(). A RDF graph that is created by a non-admin user (that is, by any user who does not have the admin role) must have at least one update permission, otherwise the creation will throw an XDMP-MUSTHAVEUPDATE exception. The parameter is ignored if the operation does not involve graph creation.

Required Privileges

Requires the sparql-update-user role, or the following privileges:




Usage Notes

You cannot use an in-memory store with SPARQL Update.

The options parse-check and prepare cannot be used at the same time.


var sem = require("/MarkLogic/semantics.xqy");

// Insert a triple into default graph and three triples into graph <BOOKS>.
PREFIX dc: <http://marklogic.com/dc/elements/1.1/>\n\
   <http://example/book0> dc:title "A default book"\n\
  GRAPH <BOOKS> {<http://example/book1> dc:title "A new book" }\n\
  GRAPH <BOOKS> {<http://example/book2> dc:title "A second book" }\n\
  GRAPH <BOOKS> {<http://example/book3> dc:title "A third book" }\n\


// Update any book title which is "A new book" to be "Insert MarkLogic Server".

PREFIX dc: <http://marklogic.com/dc/elements/1.1/>\n\
DELETE {?b dc:title "A new book" }\n\
INSERT {?b dc:title "Inside MarkLogic Server" }\n\
WHERE {\n\
  ?b dc:title "A new book" .\n\


    Powered by MarkLogic Server 7.0-4.1 and rundmc | Terms of Use | Privacy Policy