Paul,

Could you simplify the example please?

What is the output of a query that does the WHERE clause when executed after the first update?

If it has multiple matches (and it looks to me as if it will, so multiple rows with ?thing_doc, same value each time), then the INSERT in update 2 is going to put in different blank nodes, for each time the template is instantiated. If there are >= 2 rows from the WHERE, that's multiple, different blank nodes.

        Andy

PS Did you mean a doubly nested OPTIONAL?  The layout suggests not.

On 31/10/15 23:37, Paul Tyson wrote:
DELETE/INSERT operation does not work as expected using tdbupdate in
jena-3.0.0.

Starting with an empty TDB, I run the following two updates. The first
works as expected, adding 6 triples. The second should remove those
triples and add 9 new ones. Instead, the graph now has 20 triples. I did
not analyze them closely to see where they might be coming from.

If I run the DELETE clause of the 2nd update separately, it removes the
expected triples, and then the INSERT by itself will add the expected
triples.

===== 1st DELETE/INSERT =====
prefix rdf: <http://www.w3.org/1999/02/22-rdf-syntax-ns#>
prefix rdfs: <http://www.w3.org/2000/01/rdf-schema#>
prefix ex: <http://example.org/ns/foo#>
DELETE {
?thing_old rdfs:isDefinedBy ?thing_doc ;
   rdf:type ?old_type;
   ex:term ?old_term;
   ex:gAlt ?old_alt .
?old_alt ?old_alt_p ?old_alt_o .
}
INSERT {
_:b1 a ex:Thing1 ;
  rdfs:isDefinedBy ?thing_doc;
  ex:term "ABCD";
  ex:gAlt [a ex:Thing2;ex:gSyn "Automatic Widget"];
.
}
WHERE {
VALUES (?thing_doc) {(<http://example.org/doc/20849DBD>)}
OPTIONAL {?thing_old rdfs:isDefinedBy ?thing_doc ;
   rdf:type ?old_type ;
   ex:term ?old_term .
OPTIONAL {?thing_old ex:gAlt ?old_alt.
   ?old_alt ?old_alt_p ?old_alt_o.}}
}

===== 2nd DELETE/INSERT =====
prefix rdf: <http://www.w3.org/1999/02/22-rdf-syntax-ns#>
prefix rdfs: <http://www.w3.org/2000/01/rdf-schema#>
prefix ex: <http://example.org/ns/foo#>
DELETE {
?thing_old rdfs:isDefinedBy ?thing_doc ;
   rdf:type ?old_type;
   ex:term ?old_term;
   ex:gAlt ?old_alt .
?old_alt ?old_alt_p ?old_alt_o .
}
INSERT {
_:b1 a ex:Thing1 ;
  rdfs:isDefinedBy ?thing_doc;
  ex:term "ABCD";
  ex:gAlt [a ex:Thing2;ex:gSyn "Automatic Widget"];
  ex:gAlt [a ex:Thing2;ex:gSyn "Automated Widget"];
.

}
WHERE {
VALUES (?thing_doc) {(<http://example.org/doc/20849DBD>)}
OPTIONAL {?thing_old rdfs:isDefinedBy ?thing_doc ;
   rdf:type ?old_type ;
   ex:term ?old_term .
OPTIONAL {?thing_old ex:gAlt ?old_alt.
   ?old_alt ?old_alt_p ?old_alt_o.}}
}



Reply via email to