<docbook><section><title>VirtTipsAndTricksSPARQL11VALUES</title><title>Virtuoso SPARQL 1.1.
 VALUES Usage Examples</title>Virtuoso SPARQL 1.1.
 VALUES Usage Examples
<para> </para>
<bridgehead class="http://www.w3.org/1999/xhtml:h2">What?</bridgehead>
 This guide contains Virtuoso SPARQL 1.1.
 VALUES Usage example queries which you can run against any SPARQL endpoint that supports SPARQL 1.1 and the ability to allow a verified user perform INSERT operations.<bridgehead class="http://www.w3.org/1999/xhtml:h2">Why?</bridgehead>
 SPARQL 1.1 provides a mechanism for inline incorporation of Data as part SPARQL query patterns.<bridgehead class="http://www.w3.org/1999/xhtml:h2">How?</bridgehead>
<para>Here are some examples showcasing Virtuoso&#39;s support for this functionality:</para>
<orderedlist spacing="compact"><listitem>Assume the following statement for inserting triples INTO DBMS or Store: <programlisting>PREFIX :     &lt;http://example.org/book/&gt; 
PREFIX ns:   &lt;http://example.org/ns#&gt; 

INSERT 
  { 
    GRAPH &lt;urn:sparql:bind:tests&gt; 
      {
        :book1  &lt;http://purl.org/dc/elements/1.1/title&gt; &quot;SPARQL Tutorial&quot; . 
        :book1  ns:price                                42 . 
        :book1  ns:discount                             0.2 . 
        :book2  &lt;http://purl.org/dc/elements/1.1/title&gt; &quot;The Semantic Web&quot; . 
        :book2  ns:price                                23 . 
        :book2  ns:discount                             0.25 . 
      }
  }
</programlisting></listitem>
<listitem>From a Virtuoso SPARQL Endpoint ( <ulink url="http://host:port/sparql">http://host:port/sparql</ulink>  ) query the graph by executing the query from below for ex.: <programlisting>PREFIX :     &lt;http://example.org/book/&gt; 
PREFIX ns:   &lt;http://example.org/ns#&gt; 

SELECT ?book ?title ?price  
FROM &lt;urn:sparql:bind:tests&gt;  
WHERE 
  {  
    VALUES ?book { :book1 :book3 } 
    ?book &lt;http://purl.org/dc/elements/1.1/title&gt; ?title ; 
                                         ns:price ?price . 
  }
</programlisting><orderedlist spacing="compact"><listitem><ulink url="http://bit.ly/1mHUVGI">View the SPARQL Query Definition via SPARQL Protocol URL</ulink>; </listitem>
<listitem><ulink url="http://bit.ly/1i75jDz">View the SPARQL Query Results via SPARQL Protocol URL</ulink>; </listitem>
</orderedlist></listitem>
<listitem>Alternative variant of the query: <programlisting>PREFIX :     &lt;http://example.org/book/&gt; 
PREFIX ns:   &lt;http://example.org/ns#&gt; 

SELECT ?book ?title ?price 
FROM &lt;urn:sparql:bind:tests&gt; 
WHERE
  {
    ?book &lt;http://purl.org/dc/elements/1.1/title&gt; ?title ; 
                                         ns:price ?price . 
    VALUES (?book ?title) 
    { (UNDEF &quot;SPARQL Tutorial&quot;) 
      (:book2 UNDEF) 
    } 
  }
</programlisting><orderedlist spacing="compact"><listitem><ulink url="http://bit.ly/1fRt1Dz">View the SPARQL Query Definition via SPARQL Protocol URL</ulink>; </listitem>
<listitem><ulink url="http://bit.ly/VnjeeG">View the SPARQL Query Results via SPARQL Protocol URL</ulink>.</listitem>
</orderedlist></listitem>
</orderedlist><para> </para>
<bridgehead class="http://www.w3.org/1999/xhtml:h2">Related</bridgehead>
<itemizedlist mark="bullet" spacing="compact"><listitem><ulink url="http://www.w3.org/TR/sparql11-query/#inline-data">SPARQL 1.1. inline data via use of VALUES clause</ulink> </listitem>
<listitem><ulink url="VirtTipsAndTricksGuide">Virtuoso Tips and Tricks Collection</ulink> </listitem>
<listitem><ulink url="VirtTipsAndTricksSPARQL11FeaturesExamplesCollection">Virtuoso SPARQL 1.1 Usage Examples Collection</ulink> </listitem>
<listitem><ulink url="http://virtuoso.openlinksw.com/tutorials/sparql/SPARQL_Tutorials_Part_9/SPARQL_Tutorials_Part_9.html">Virtuoso SPARQL 1.1 Syntax Tutorial</ulink> </listitem>
<listitem><ulink url="http://bit.ly/U0q7Hb">Virtuoso SPARQL 1.1 VALUES Tutorial</ulink> </listitem>
<listitem><ulink url="http://bit.ly/Uo5hP6">Virtuoso SPASQL And SPARQL Tutorial</ulink> </listitem>
<listitem><ulink url="http://docs.openlinksw.com/virtuoso/rdfsparql.html">Virtuoso Documentation</ulink></listitem>
</itemizedlist><para> </para>
</section></docbook>