<?xml version="1.0" encoding="UTF-8"?><api:function-page xml:base="/apidoc/8.0/sem.sparqlUpdate.xml" generated="2015-10-07T16:36:00.016766-07:00" mode="javascript" xmlns:api="http://marklogic.com/rundmc/api"><api:function-name>sem.sparqlUpdate</api:function-name><api:suggest>sem.sparqlupdate</api:suggest><api:suggest>sem</api:suggest><api:suggest>sparqlupdate</api:suggest><api:function-link mode="xquery" fullname="sem:sparql-update">/apidoc/8.0/sem:sparql-update.xml</api:function-link><api:function mode="javascript" name="sparqlUpdate" type="builtin" lib="sem" category="Semantics" hidden="false" bucket="MarkLogic Built-In Functions" prefix="sem" namespace="http://marklogic.com/semantics" fullname="sem.sparqlUpdate"><api:summary>
  Executes a SPARQL Update operation against the database.
    <p xmlns="http://www.w3.org/1999/xhtml">Graph Update - addition and removal of triples from some graphs within
    the Graph Store.</p>
    <p xmlns="http://www.w3.org/1999/xhtml">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).</p>
	<p xmlns="http://www.w3.org/1999/xhtml">This function is a built-in.</p>
</api:summary><api:params><api:param name="sparql" type="xs:string"><api:param-description>
    The SPARQL Update to be executed.
  </api:param-description><api:param-name>sparql</api:param-name><api:param-type>String</api:param-type></api:param><api:param name="bindings" type="map:map?" optional="true"><api:param-description>
    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.
  </api:param-description><api:param-name>bindings</api:param-name><api:param-type>Object?</api:param-type></api:param><api:param name="options" type="xs:string*" optional="true"><api:param-description>
    Options as a sequence of string values. Available options are:
    <dl xmlns="http://www.w3.org/1999/xhtml">
    <dt>"base=<em>IRI</em>"</dt>
    <dd>The initial base IRI for the query.</dd>
    <dt>"default-graph=<em>IRI</em>*"</dt>
    <dd>Add the named graph or graphs specified by the IRI to the default graph for 
    the query.</dd>
    <dt>"named-graph=<em>IRI</em>*"</dt>
    <dd>Add the named graph or graphs specified by the IRI to the list of named graphs 
    available in the query.</dd>
    <dt>"parse-check"</dt>
    <dd>Parse the query, but don't perform static checks or execute it.</dd>
    <dt>"prepare"</dt>
    <dd>Parse and optimize the query, caching the result. No execution is 
    performed.</dd>
    <dt>"optimize=N"</dt>
    <dd>Sets the optimization level to use. Levels of 0 (off), 1, and 2 are 
    recognized, with 1 as the default.</dd>
    <dt>"directory=URI"</dt>
    <dd>Sets The database directory path of triples document. Default location 
    is /triplestore.</dd>
    <dt>"triples-document-size=xs:nonNegativeInteger"</dt>
    <dd>The number of triples in a triples document. Default is 100.</dd>
    <dt>"existing-graph"</dt>
    <dd>Update fails if the specified destination graph does not already 
    exist.</dd>
    <dt>"isolation=ISOLATION_LEVEL"</dt>
    <dd>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.</dd>
    <dt>"transaction-id=TXN_ID"</dt>
    <dd>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.</dd>
    </dl>
  </api:param-description><api:param-name>options</api:param-name><api:param-type>String[]</api:param-type></api:param><api:param name="store" type="sem:store*" optional="true"><api:param-description>
    A <code xmlns="http://www.w3.org/1999/xhtml">sem:store</code> value to use as the source of the triples for 
    the SPARQL query. If multiple <code xmlns="http://www.w3.org/1999/xhtml">sem:store</code> values are supplied, 
    the triples from all the sources are merged and queried together. The 
	default for <code xmlns="http://www.w3.org/1999/xhtml">sem:store</code> is the triples that can be inferred 
	from the rulesets. The locking option specified in <code xmlns="http://www.w3.org/1999/xhtml">sem:store</code> 
	will be used by <code xmlns="http://www.w3.org/1999/xhtml">sem:sparql-update</code>. The default locking option
	for <code xmlns="http://www.w3.org/1999/xhtml">sem:store</code> is <code xmlns="http://www.w3.org/1999/xhtml">read-write</code>; read-lock documents 
	containing 	triples being accessed, write-lock documents being modified. 
	Locking can	also be set to <code xmlns="http://www.w3.org/1999/xhtml">write</code>; only write-lock documents 
	being modified. The <code xmlns="http://www.w3.org/1999/xhtml">sem:sparql-update</code> operation will run with
	the locking option specified in <code xmlns="http://www.w3.org/1999/xhtml">sem:store</code>. Locking is ignored
	in a query transaction. 
	<p xmlns="http://www.w3.org/1999/xhtml"> 
	If <code>sem:store</code> is a <code>cts:query</code>, <code>sem:store</code>
	will use the default locking option (<code>read-write</code>).
	</p>
    <p xmlns="http://www.w3.org/1999/xhtml">
	If a <code>sem:store</code> value is not supplied then the default 
    <code>sem:store</code> for the statement will be used, and the default 
    locking is <code>read-write</code>. This has the same configuration as calling 
    <code>sem:store()</code> with all arguments omitted, which will access 
    the current database's triple index, using the default rulesets 
    configured for that database.
    </p>
  </api:param-description><api:param-name>store</api:param-name><api:param-type>sem.store[]</api:param-type></api:param><api:param class="javascript" name="default-permissions" type="Object[]" optional="true"><api:param-description>
    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 
    <code xmlns="http://www.w3.org/1999/xhtml">xdmp.defaultPermissions()</code>. 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.
  </api:param-description><api:param-name>default-permissions</api:param-name><api:param-type>Object[]</api:param-type></api:param></api:params><api:return>null</api:return><api:privilege>
<p xmlns="http://www.w3.org/1999/xhtml">Requires the <code>sparql-update-user</code> role, or the following 
privileges:</p>
<p xmlns="http://www.w3.org/1999/xhtml"><code>http://marklogic.com/xdmp/privileges/sem-sparql-update</code></p>
<p xmlns="http://www.w3.org/1999/xhtml"><code>http://marklogic.com/xdmp/privileges/any-uri</code></p>
<p xmlns="http://www.w3.org/1999/xhtml"><code>http://marklogic.com/xdmp/privileges/unprotected-collections</code></p>
</api:privilege><api:usage>
   <p xmlns="http://www.w3.org/1999/xhtml">The options <code>parse-check</code> and <code>prepare</code> cannot be
   used at the same time.</p>
</api:usage><api:example class="javascript"><pre xml:space="preserve" xmlns="http://www.w3.org/1999/xhtml">
declareUpdate();
var sem = require("/MarkLogic/semantics.xqy");

// Insert a triple into default graph and three triples into graph &lt;BOOKS&gt;. 
sem.sparqlUpdate('\n\
PREFIX dc: &lt;http://marklogic.com/dc/elements/1.1/&gt;\n\
INSERT DATA\n\
{\n\
   &lt;http://example/book0&gt; dc:title "A default book"\n\
  GRAPH &lt;BOOKS&gt; {&lt;http://example/book1&gt; dc:title "A new book" }\n\
  GRAPH &lt;BOOKS&gt; {&lt;http://example/book2&gt; dc:title "A second book" }\n\
  GRAPH &lt;BOOKS&gt; {&lt;http://example/book3&gt; dc:title "A third book" }\n\
}\n\
');
</pre></api:example><api:example class="javascript"><pre xml:space="preserve" xmlns="http://www.w3.org/1999/xhtml">
// Update any book title which is "A new book" to be "Insert MarkLogic Server".

declareUpdate();
sem.sparqlUpdate('\n\
PREFIX dc: &lt;http://marklogic.com/dc/elements/1.1/&gt;\n\
WITH &lt;BOOKS&gt;\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\
}\n\
');

</pre></api:example></api:function></api:function-page>