8.6 SPARQL Update Execution Model

This section explains the SPARQL Update Execution Model for Oracle RDF Graph Adapter for Eclipse RDF4J.

The adapter for Eclipse RDF4J implements SPARQL update operations by executing the SEM_APIS.UPDATE_RDF_GRAPH stored procedure on the database server. You can execute a SPARQL update operation by getting an Update object from the prepareUpdate function of an instance of OracleSailRepositoryConnection.

Note:

You must have an OracleSailRepositoryConnection instance. A plain SailRepository instance created from an OracleSailStore will not run the update properly.

The following example illustrates how to update an Oracle RDF graph through the RDF4J API:

String updString =
   "PREFIX people: <http://www.example.org/people/>\n"+
   "PREFIX    ont: <http://www.example.org/ontology/>\n"+        
   "INSERT DATA { GRAPH <urn:g1> { \n"+        
   "                people:Sue a ont:Person; \n"+        
   "                             ont:name \"Sue\" . } }";      
   Update upd = conn.prepareUpdate(QueryLanguage.SPARQL, updString);      
   upd.execute();

8.6.1 Transaction Management for SPARQL Update

SPARQL update operations executed through the RDF4J API follow standard RDF4J transaction management conventions. SPARQL updates are committed automatically by default. However, if an explicit transaction is started on the SailRepositoryConnection with begin, then subsequent SPARQL update operations will not be committed until the active transaction is explicitly committed with commit. Any uncommitted update operations can be rolled back with rollback.

8.6.2 Additions to the SPARQL Syntax to Support Other Features

Just as it does with SPARQL queries, Oracle RDF Graph Adapter for Eclipse RDF4J allows you to pass in options for SPARQL update execution. It implements these capabilities by overloading the SPARQL namespace prefix syntax by using Oracle-specific namespaces that contain SEM_APIS.UPDATE_RDF_GRAPH options.

8.6.2.1 UPDATE_RDF_GRAPH Options

You can pass options to SEM_APIS.UPDATE_RDF_GRAPH by including a PREFIX declaration with the following form:
PREFIX ORACLE_SEM_UM_NS: <http://oracle.com/semtech#option>
The option in the above PREFIX reflects an UPDATE_RDF_GRAPH option (or multiple options separated by commas) to be used during update execution.

See SEM_APIS.UPDATE_RDF_GRAPH for more information on available options. Any valid keywords or keyword – value pairs listed as valid for the options argument of UPDATE_RDF_GRAPH can be used with this PREFIX.

The following example query uses the ORACLE_SEM_UM_NS prefix to specify a degree of parallelism of 2 for the update.

PREFIX ORACLE_SEM_UM_NS: <http://oracle.com/semtech#parallel(2)>
PREFIX ex: <http://www.example.org/>
INSERT {GRAPH ex:g1 {ex:a ex:reachable ?y}}
WHERE {ex:a ex:p1* ?y}

8.6.2.2 UPDATE_RDF_GRAPH Match Options

You can pass match options to SEM_APIS.UPDATE_RDF_GRAPH by including a PREFIX declaration with the following form:

PREFIX ORACLE_SEM_SM_NS: <http://oracle.com/semtech#option>

The option reflects an UPDATE_RDF_GRAPH match option (or multiple match options separated by commas) to be used during SPARQL update execution.

The available options are detailed in SEM_APIS.UPDATE_RDF_GRAPH. Any valid keywords or keyword – value pairs listed as valid for the match_options argument of UPDATE_RDF_GRAPH can be used with this PREFIX.

The following example uses the ORACLE_SEM_SM_NS prefix to specify a maximum unbounded property path depth of 5.

PREFIX ORACLE_SEM_SM_NS: <http://oracle.com/semtech#all_max_pp_depth(5)>
PREFIX ex: <http://www.example.org/>
INSERT {GRAPH ex:g1 {ex:a ex:reachable ?y}}
WHERE {ex:a ex:p1* ?y}

8.6.3 Special Considerations for SPARQL Update Support

Unbounded Property Paths in Update Operations

As mentioned in the previous section, Oracle RDF Graph Adapter for Eclipse RDF4J limits the evaluation of the unbounded SPARQL property path operators + and * to at most 10 repetitions. This default setting will affect SPARQL update operations that use property paths in the WHERE clause. The max repetition setting can be controlled with the all_max_pp_depth(n) option, where n is the maximum allowed number of repetitions when matching + or *. Specifying a value of zero results in unlimited maximum repetitions.

The following example uses all_max_pp_depth(0) as a match option for SEM_APIS.UPDATE_RDF_GRAPH for a fully unbounded search.

PREFIX ORACLE_SEM_SM_NS: <http://oracle.com/semtech#all_max_pp_depth(0)>
PREFIX ex: <http://www.example.org/>
INSERT { GRAPH ex:g1 { ex:a ex:reachable ?y}}
WHERE { ex:a ex:p1* ?y}

SPARQL Dataset Specification

Oracle RDF Graph Adapter for Eclipse RDF4J does not allow dataset specification outside of the SPARQL update string. Dataset specification through the setDataset method of Operation and its subinterfaces is not supported. Instead, use the WITH, USING and USING NAMED SPARQL clauses to specify the dataset in the SPARQL update string itself.

Bind Values

Bind values are not supported for SPARQL update operations.

Long RDF Literals

As noted in the previous section, large RDF literal values greater than 4000 bytes in length are not supported by some SPARQL query functions. This limitation will affect SPARQL update operations using any of these functions on long literal data. See Special Considerations When Using SEM_MATCH for more information.

Update Timeout

Update timeout through the setMaxExecutionTime method on Operation and its subinterfaces is not supported.