Skip to content
This repository was archived by the owner on Feb 17, 2025. It is now read-only.

Update Datasets

Efimster edited this page Mar 24, 2014 · 2 revisions

The INSERT/DELETE command in SPARQL Update allows the dataset to be specified in several ways: The WITH clause specifies a default graph for the INSERT and DELETE portions of the query The USING clauses specifies the graphs that form the default graph for the WHERE portion of the update. If there are no USING clauses the WITH clause specifies the default graph, if there is no WITH then the default graph is dataset specific. The USING NAMED clause specifies the named graphs for the WHERE portion of the update and may be accessed using a GRAPH clause in your query.

Samples:

dyno.Update(
                prefixes: new[] {
                    SPARQL.Prefix("foaf", "http://xmlns.com/foaf/0.1/"),
                    SPARQL.Prefix("ns", "http://example.org/ns#")
                },
                with: "ns:g1",//WITH clause
                delete: SPARQL.Triple("?person foaf:givenName Bill"),
                insert: SPARQL.Triple("?person foaf:givenName William"),
                Using: "ns:g1",//USING clause
                where: SPARQL.Triple("?person foaf:givenName Bill")
            );
dyno.Update(
               prefixes: new[] {
                                SPARQL.Prefix("foaf", "http://xmlns.com/foaf/0.1/"),
                                SPARQL.Prefix("ns", "http://example.org/ns#")
                            },
               with: "ns:g2", // WITH clause
               delete: SPARQL.Triple("?person foaf:givenName Bill"),
               insert: SPARQL.Triple("?person foaf:givenName Ben"),
               UsingNamed: "ns:g2", //or new[] { "ns:g2" } - USING NAMED clause   
               where: SPARQL.Graph("?g",  // GRAPH pattern within WHERE clause
                   SPARQL.Triple("?person foaf:givenName Bill"))
           );

Clone this wiki locally