Virtuoso Open-Source Edition

  • Topic
  • Discussion
  • How can I use CONSTRUCT with Prepared Statements?

    Assume a given query which uses pragma output:format '_JAVA_' with CONSTRUCT:
    SPARQL DEFINE output:format '_JAVA_'
       CONSTRUCT { ?s ?p ?o }
    WHERE
      { 
        ?s ?p ?o . 
        FILTER (?s = iri(?::0)) 
      }
    LIMIT 1
    

    In order to work correctly, the query should be modified to:

    SPARQL DEFINE output:format '_JAVA_'
       CONSTRUCT { `iri(?::0)` ?p ?o }
    WHERE
      { 
        `iri(?::0)` ?p ?o 
      }
    LIMIT 1
    

    Equivalent variant of the query is also:

    SPARQL DEFINE output:format '_JAVA_'
      CONSTRUCT { ?s ?p ?o }
    WHERE
      { 
        ?s ?p ?o . 
        FILTER (?s = iri(?::0)) 
      }
    LIMIT 1
    

    Related