Thank you Paul for your very clear answer.

Do you know if there is a technical reason for not providing
additional methods that return deleted/altered entries or a counter?
It seems strange for  me that the specification do not discuss about
that.

Kind Regards,

Laurent

On Tue, Sep 4, 2012 at 7:31 PM, Paul Gearon <[email protected]> wrote:
> On Tue, Sep 4, 2012 at 10:27 AM, Laurent Pellegrino
> <[email protected]> wrote:
>> Hello all,
>>
>> Is it possible to retrieve the entries which have been deleted/updated
>> during the execution of a SPARQL update query or at least to know the
>> number of entries which have been altered?
>
> Not specifically, no.
>
> However, you can probably figure it out before you do the operation.
> Most INSERT or DELETE operations can be converted into a CONSTRUCT or
> SELECT query, which gives you a starting point. For an INSERT you can
> then figure out the new data using EXISTS, and for DELETE you can use
> NOT EXISTS.
>
> So, say you want to execute:
>
> INSERT { ?s foaf:name ?name }
> WHERE { ?s foaf:givenName ?gn .
>   ?s foaf:familyName ?fn
>   BIND (concat(?gn, " ", ?fn) as ?name)
> }
>
> To see the attempted insertions, you just change this to:
>
>
> SELECT ?s (foaf:name AS ?prop) ?name
> WHERE { ?s foaf:givenName ?gn .
>   ?s foaf:familyName ?fn
>   BIND (concat(?gn, " ", ?fn) as ?name)
> }
>
> The use of "AS ?prop" allows the inclusion if an IRI in the result
> set, which is needed if you want to see the middle column in a SELECT
> (you could just drop the middle column here, but I'm trying to make it
> look consistent with triples that are inserted). CONSTRUCT doesn't
> need this.
>
> To restrict to just the data you want to insert, you can use:
>
> SELECT ?s (foaf:name AS ?prop) ?name
> WHERE { ?s foaf:givenName ?gn .
>   ?s foaf:familyName ?fn
>   BIND (concat(?gn, " ", ?fn) as ?name)
>   FILTER NOT EXISTS { ?s foaf:name ?name }
> }
>
> To see the number of entries, just replace the variables in the SELECT
> clause with a COUNT(DISTINCT *)
>
>
> SELECT COUNT(DISTINCT *)
> WHERE { ?s foaf:givenName ?gn .
>   ?s foaf:familyName ?fn
>   BIND (concat(?gn, " ", ?fn) as ?name)
>   FILTER NOT EXISTS { ?s foaf:name ?name }
> }
>
> A similar approach may be taken for DELETE. An expression that
> performs both INSERT and DELETE may be more difficult in the general
> case, but should be tractable for most applications.
>
> Regards,
> Paul Gearon

Reply via email to