SPARQL update on more triples in more than one GRAPH

Hi,

This might be a generic SPARQL question, or maybe the answer is more specific to Stardog (depending on how it manages the "default" graph).

Given an update query as:
WITH http://mygraph
DELETE {?obj :myProp false}
INSERT {?obj :myProp true}
WHERE {?obj :myProp false}

Is there a way to perform such an update on all the graphs that contain "?obj :myProp false" triples ?
From my understanding: We can either specify a WITH clause for one specific graph, or omit the WITH clause and work on the default graph.

In my trials, when omitting the WITH clause, no update was performed, eventhough the "Query all graph=true" is set.

Thank you for any pointer
Fabian

Hi Fabian,

DELETE and INSERT clauses allow quad templates:

pavel$ stardog query test "insert data { <urn:g1> { <urn:a> <urn:p> 0  } <urn:g2> { <urn:a> <urn:p> 0 }  }"
2 triples added in 00:00:00.028
pavel$ stardog query test "select * { graph ?g { ?s ?p ?o  }}"
+--------+-------+-------+-------+
|   g    |   s   |   p   |   o   |
+--------+-------+-------+-------+
| urn:g1 | urn:a | urn:p | 0     |
| urn:g2 | urn:a | urn:p | 0     |
+--------+-------+-------+-------+

Query returned 2 results in 00:00:00.047
pavel$ stardog query test " delete { graph ?g { ?s ?p 0  }  } insert { graph ?g { ?s ?p 1  } } where { graph ?g { ?s ?p 0 }  }"
2 triples added, 2 triples removed in 00:00:00.033
pavel$ stardog query test "select * { graph ?g { ?s ?p ?o  }}"
+--------+-------+-------+-------+
|   g    |   s   |   p   |   o   |
+--------+-------+-------+-------+
| urn:g1 | urn:a | urn:p | 1     |
| urn:g2 | urn:a | urn:p | 1     |
+--------+-------+-------+-------+

Query returned 2 results in 00:00:00.044

Cheers,
Pavel

Thank you for your answer Pavel.

I was aware of that, but maybe my question was not clear enough.

A more accurate question would be:
Is it possible to perform an update WITHOUT specifying the named graphs to update, just asking to upgrade all corresponding triples IN ANY named graph ?

Thanks
Fabian

Isn’t it what I did with this query?

stardog query test " delete { graph ?g { ?s ?p 0  }  } insert { graph ?g { ?s ?p 1  } } where { graph ?g { ?s ?p 0 }  }"

It doesn’t specify any concrete named graphs, it updates all those in which the pattern ?s ?p 0 is matched.

Cheers,
Pavel

This topic was automatically closed 14 days after the last reply. New replies are no longer allowed.