How can I Delete Triple Patterns that are Not Scoped to a Named Graph?

Presuming this triple exists in one or more graphs in the store:


{ <http://kingsley.idehen.net/dataspace/person/kidehen#this> 
    <http://xmlns.com/foaf/0.1/knows> 
      <http://id.myopenlink.net/dataspace/person/KingsleyUyiIdehen#this> 
}

The SQL query below will delete that triple from all graphs in the store:


DELETE 
  FROM DB.DBA.RDF_QUAD 
 WHERE p = iri_to_id
             ('http://xmlns.com/foaf/0.1/knows') 
   AND s = iri_to_id 
             ('http://kingsley.idehen.net/dataspace/person/kidehen#this') 
   AND o = iri_to_id 
             ('http://id.myopenlink.net/dataspace/person/KingsleyUyiIdehen#this')
;

According to SPARQL 1.1 Update, the FROM clause which scopes the query to a single graph is optional. Thus, the SQL query above can be rewritten to the SPARQL query below, again deleting the matching triple from all graphs in the store:


DELETE 
  { 
    GRAPH ?g 
      { 
        <http://kingsley.idehen.net/dataspace/person/kidehen#this> 
          <http://xmlns.com/foaf/0.1/knows> 
            <http://id.myopenlink.net/dataspace/person/KingsleyUyiIdehen#this> 
      } 
  }
WHERE 
  { 
    GRAPH ?g 
      { 
        <http://kingsley.idehen.net/dataspace/person/kidehen#this> 
          <http://xmlns.com/foaf/0.1/knows> 
            <http://id.myopenlink.net/dataspace/person/KingsleyUyiIdehen#this> 
      } 
  }

Related