sparqlrdftriplestore

Removing all predicates of a given subject via SPARQL


I am trying to delete a known URI from our triplestore. It can be a subject or an object, by its predicates. So what I like to do is the following:

DELETE { 
    GRAPH <graph> {
        <uri> ?p1 ?o1 .
        ?s2 ?p2 <uri> .
    }
}

By executing the following query, all occurences of the known should be removed in the known . However I cannot use variables in a delete function. How can I make the above code working?


Solution

  • DELETE needs a template 9what to delete) and a pattern (binds variables).

    There is the DELETE WHERE operation. https://www.w3.org/TR/sparql11-update/#deleteWhere

    DELETE WHERE { .... is a short form of DELETE {...} WHERE {...} with the same {...} for template and pattern.