HI Mirko,
I have problems understanding parameters in sparql queries. I read
section 16.2.6 of the docs (http://docs.openlinksw.com/virtuoso/
rdfsparql.html#rdfsparqlinline
), but still don't succeed passing IRIs. I would appreciate an
example. E.g., how can I parametrize the object in the following
query:
SELECT ?x FROM <http://www.mygraph.org> WHERE { ?x <http://purl.org/
dc/elements/1.1/creator
<http://myusers/xyz> }
My attempt (in Java) returns nothing, presumably because the parameter
is interpreted as a String value:
PreparedStatement stmt = con.prepareStatement("SELECT ?x FROM
<http://www.mygraph.org
WHERE { ?x <http://purl.org/dc/elements/1.1/creator> ?? }");
stmt.setString(1, "http://myusers/xyz");
I suggest you read the following part of the online documentation:
http://docs.openlinksw.com/virtuoso/rdfapiandsql.html
As you indeed thought a parameter like "http://myusers/xyz" is not
the same as the <http://myusers/xyz>. In some constructions virtuoso
is capable of determining the intended use of the parameter from the
context like "graph ??", but in other cases a parameter will be
interpreted as a String.
You can use the following construction (formatted for readability):
PreparedStatement stmt = con.prepareStatement ("
SELECT ?x FROM <http://www.mygraph.org>
WHERE { ?x <http://purl.org/dc/elements/1.1/creator> `iri(??)` }
");
stmt.setString(1, "http://myuser/xyz");
Best regards,
Patrick