How to iterate on a SPARQL query, referencing a virtual graph?

I am developing a Virtuoso stored procedure. I want to run a loop based on the result of a SPARQL query on a graph. The problem occurs when the request contains a link to a virtual graph (the graph is not physically located in the triplestore, which is the result of the R2RML conversion operation). In all my attempts, I get no error except an empty result set. 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");
    }
};

as well as 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, iteration is not performed, despite the same query, when executed at the endpoint of SPARQL, returns the result.

If I remove the link to the chart, iterations are performed:

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");
    }
};

Does anyone have an idea that I'm wrong?

+4
1

, , define SPARQL. , Quad Virtuoso, define .

sparql define input:storage "http://www.openlinksw.com/schemas/virtrdf#DefaultQuadStorage"
0

Source: https://habr.com/ru/post/1670724/


All Articles