Search code examples
sparqlsemantic-websesamelinked-data

Sesame repository not being updated using INSERT despite no error


I am trying to update a Sesame repository with data from dbpedia. I have the following query:

PREFIX owl: <http://www.w3.org/2002/07/owl#>
PREFIX xsd: <http://www.w3.org/2001/XMLSchema#>
PREFIX rdfs: <http://www.w3.org/2000/01/rdf-schema#>
PREFIX rdf: <http://www.w3.org/1999/02/22-rdf-syntax-ns#>
PREFIX foaf: <http://xmlns.com/foaf/0.1/>
PREFIX dc: <http://purl.org/dc/elements/1.1/>
PREFIX : <http://dbpedia.org/resource/>
PREFIX dbpedia2: <http://dbpedia.org/property/>
PREFIX dbpedia: <http://dbpedia.org/>
PREFIX skos: <http://www.w3.org/2004/02/skos/core#>

INSERT{?s ?p ?o}

WHERE {
 SERVICE <http://dbpedia.org/sparql>{

{:Rotavirus_vaccine ?p ?o.
}
UNION
{
?s ?p :Rotavirus_vaccine.
}
}
}

This query doesn't show any error doesn't update the repository. On the other hand, splitting the UNION into two separate queries and then updating the repository one by one works. Why do the queries work in isolation but not in union? The code of an individual query is:

INSERT{:Rotavirus_vaccine ?p ?o}        
WHERE {
SERVICE <http://dbpedia.org/sparql>{
{:Rotavirus_vaccine ?p ?o.
}
}
}

Solution

  • I've been able to execute a functional query by using BIND for both clauses of the UNION. The code is:

    INSERT{?s ?p ?o} 
    WHERE 
    { 
    SERVICE <dbpedia.org/sparql>
    { 
    {:Rotavirus_vaccine ?p ?o. BIND(:Rotavirus_vaccine AS ?s)} 
    UNION {?s ?p :Rotavirus_vaccine. BIND(:Rotavirus_vaccine AS ?o) } 
    } 
    }