I am developing a Virtuoso stored procedure. I want to perform a loop over the result of a SPARQL query to a graph. The problem comes when the query contains a reference to a virtual graph (a graph not physically in the triplestore, being the result of a R2RML mapping operation). In all my attempts I get no error but an empty resultset as well. I tried the following
create procedure R2RML.DBA.try() returns integer
{
for (sparql define input:storage ""
select ?s ?p
from <http://example.com/resource>
where {
?s <http://www.w3.org/1999/02/22-rdf-syntax-ns#type> ?o .
} LIMIT 5 ) do
{
use_the_value("s");
}
};
and also the following
create procedure R2RML.DBA.try() returns integer
{
declare srcgraph varchar;
srcgraph := 'http://ec.example.com/resource';
for (sparql define input:storage ""
select ?s ?p
where {
GRAPH `iri(?:srcgraph)`
{
?s <http://www.w3.org/1999/02/22-rdf-syntax-ns#type> ?o .
}
} LIMIT 5 ) do
{
use_the_value("s");
}
};
In both cases no iteration is performed, despite the same query, when executed in the SPARQL endpoint, returns a result.
If I remove the reference to the graph the iterations are executed:
create procedure R2RML.DBA.try() returns integer
{
for (sparql define input:storage ""
select ?s ?p
where {
?s <http://www.w3.org/1999/02/22-rdf-syntax-ns#type> ?o .
} LIMIT 5 ) do
{
use_the_value("s");
}
};
Has somebody any idea of what I get wrong?