Virtuoso 37000 错误 SP031:SPARQL 编译器:常量子句中不允许使用变量

问题描述 投票:0回答:1

这是我尝试用“创建”日期填充空的“发布于”日期的结果。

Virtuoso 37000 Error SP031: SPARQL compiler: Variable 'entity' is not allowed in a constant clause

SPARQL query:
define sql:big-data-const 0
#output-format:text/html
define sql:signal-void-variables 1

INSERT DATA {
  GRAPH <http://mysite.eu/collection/published> {
    ?entity <http://mysite.eu/collection/published-at> ?created
    WHERE {
      SELECT ?entity ?created WHERE {
        GRAPH <http://mysite.eu/collection/published> {
          {
            ?entity <http://purl.org/dc/terms/issued> ?created .
            OPTIONAL { ?s <http://mysite.eu/collection/published-at> ?published . }
            FILTER(!bound(?published))
          }
        }
      }
    }
  }
}

这里出了什么问题?提到的常量子句是什么?如何解决这个问题?

编辑1:

我可能会遇到类似的错误,就像使用更简单的查询一样:

Virtuoso 37000 Error SP031: SPARQL compiler: Variable 'o' is not allowed in a constant clause

SPARQL query:
define sql:big-data-const 0
#output-format:text/html
define sql:signal-void-variables 1

DELETE DATA {
  GRAPH <http://mysite.eu/collection/published> {
    <http://data.europa.eu/w21/33598e9e-2654-4639-9528-d70772837ce4> <http://mysite.eu/collection/published-at> ?o
  }
}
sparql rdf
1个回答
0
投票

此 SPARQL 更新查询无效。

INSERT DATA
操作不允许变量,
WHERE
FILTER
等。您需要使用
INSERT
操作,它有一个
WHERE
子句:

INSERT {
  # …
}

WHERE {
  # …
}

您的

WHERE
子句本身也有一个问题:
?entity
包含具有
dcterms:issued
值的所有实例。
?s
包含没有
?entity
值的所有实例(而不仅仅是
:published-at
中的实例)。因此,您可能想使用变量
?entity
而不是
?s

这样的东西可能对你有用:

PREFIX dcterms: <http://purl.org/dc/terms/>
PREFIX : <http://mysite.eu/collection/>

WITH <http://mysite.eu/collection/published> 
# only use WITH to query and write to the same graph
# if you don’t want that, you can include 'GRAPH' patterns in the 'INSERT' and in the 'WHERE' instead

INSERT {
  ?entity :published-at ?created .
}

WHERE {
  ?entity dcterms:issued ?created .
  FILTER NOT EXISTS { ?entity :published-at [] . }
}
© www.soinside.com 2019 - 2024. All rights reserved.