SPARQL update example for updating more than one triple in one query

Can someone point me to a valid UPDATE statement in SPARQL in any documentation (whether it be W3C, virtuoso, semantic web page or native user code, etc.

It should be supplemented with WHERE specifications and more than one triple updated in one request.

Thanks.

EDIT / Example:

Here is my current code, the purpose of which is to replace all current values โ€‹โ€‹of dc:creator , dc:title and dc:description with those specified in the INSERT clause. Is this query correct in both logic and syntax?

 WITH GRAPH <http://127.0.0.1:3000/dendro_graph> DELETE { :teste dc:creator ?o0 . :teste dc:title ?o1 . :teste dc:description ?o2 . } INSERT { :teste dc:creator "Creator%201" . :teste dc:creator "Creator%202" . :teste dc:title "Title%201" . :teste dc:description "Description%201" . } WHERE { :teste dc:creator ?o0 . :teste dc:title ?o1 . :teste dc:description ?o2 . } 
+7
sparql
source share
4 answers

Itโ€™s still not entirely clear to me what you are trying to achieve, and why the update example you are giving does not do what you want, but if the goal is to have an update that replaces triples for a given subject, you can do something like that:

 @prefix rdf: <http://www.w3.org/1999/02/22-rdf-syntax-ns#> @prefix ex: <http://example.org/> DELETE {?s ?p ?o} INSERT {?s ex:title "foo" ; ex:description "bar" ; rdf:type ex:FooBar . } WHERE { ?s ?p ?o . FILTER (?s = ex:subject1) } 

The above operation will delete all existing triples with ex:subject1 as an object and insert a new name, description and type.

Or, if you do not like filters, you can also formulate the following:

 @prefix rdf: <http://www.w3.org/1999/02/22-rdf-syntax-ns#> @prefix ex: <http://example.org/> DELETE {ex:subject1 ?p ?o} INSERT {ex:subject1 ex:title "foo" ; ex:description "bar" ; rdf:type ex:FooBar . } WHERE { ex:subject1 ?p ?o . } 

If you want to remove only certain properties for a given object (and not all trinities with this object), you can change the operation as follows:

 @prefix rdf: <http://www.w3.org/1999/02/22-rdf-syntax-ns#> @prefix ex: <http://example.org/> DELETE {ex:subject1 ex:title ?t ; ex:description ?d ; rdf:type ?c . } INSERT {ex:subject1 ex:title "foo" ; ex:description "bar" ; rdf:type ex:FooBar . } WHERE { ex:subject1 ex:title ?t ; ex:description ?d ; rdf:type ?c . } 
+12
source share

In SPARQL updates are presented as DELETE followed by INSERT:

http://www.w3.org/TR/2010/WD-sparql11-update-20100126/#t413

 PREFIX foaf: <http://xmlns.com/foaf/0.1/> WITH <http://example/addresses> DELETE { ?person foaf:firstName 'Bill' } INSERT { ?person foaf:firstName 'William' } WHERE { ?person a foaf:Person . ?person foaf:firstName 'Bill' } 
+4
source share

Hallelujah Praise God.

After 3 days, hitting my head against the wall, I believe that I have a solution that looks like work. First you make a DELETE , then you use a semicolon to indicate the triples you want to insert. Its two more operations, but at least they are controlled by the request server, i.e. E. You do not need to execute two separate queries, one for DELETE other for UPDATE (very dangerous).

Here is my working code, now (legally) fixed:

 WITH GRAPH <http://127.0.0.1:3000/dendro_graph> DELETE { :teste dc:creator ?o0 . :teste dc:title ?o1 . } WHERE { :teste dc:creator ?o0 . :teste dc:title ?o1 . }; 

<------ NOTE SEMICALL at the end of the first part

 INSERT DATA { :teste dc:creator "criador%20do%20teste" . :teste dc:creator "second%20criador%20do%20teste" . :teste dc:creator "third%20criador%20do%20teste" . :teste dc:creator "fourth%20criador%20do%20teste" . :teste dc:title "t1" . :teste dc:title "t3" . :teste dc:title "second%20title" . } 
+2
source share

Sparql insertion is not possible. Sparql processing for already matching and dumping rdf files. Its only query processing for attached data or data data.not data for such as mysql, sql, etc.

rdf file for the predicate format of an object object.

sparql query to select *, where {? s? p? o. } get the result

-3
source share

All Articles