Hi Ivan,
thanks a lot for the explanation. The workaround looks crazy. :)
Sadly it does not work here. But then again the following query does not
work either which is very confusing:
select ?mg where {
?mg nrl:coreGraphMetadataFor ?g .
FILTER(?g in (<xxxx>)) .
FILTER(!bif:exists((select (1) where {
graph ?g { ?s ?p ?o . } . }
))) .
}
It always returns an empty result set. What does work is using a count
as follows and then test for cnt==0 in the client code:
select ?mg
(select count(*) where { graph ?g { ?s ?p ?o . } . }) as ?cnt
where {
?mg nrl:coreGraphMetadataFor ?g .
FILTER(?g in (<xxxx>)) .
}
any idea why that could be?
Cheers,
Sebastian
On 06/30/2011 09:34 AM, Ivan Mikhailov wrote:
> Hello Sebastian,
>
> Unfortunately there's no way to calculate the graph to delete by
> something more complicated than constant expression. If that creates
> severe problems then I will extend the processor to support something
> like
>
> clear graph (
> select ?mg where {
> ?mg nrl:coreGraphMetadataFor ?g .
> FILTER(?g in (<urn:nepomuk:local:8a9e692a>)) .
> FILTER(
> !bif:exists((select (1) where { graph ?g { ?s ?p ?o . } . }))
> ) .
> } )
> ;
>
> but it will delete only the first selected graph.
>
> A workaround that can be used right now is
>
> sparql select (bif:exec(bif:sprintf("sparql clear graph <%s>", str(?mg))))
> where {
> ?mg nrl:coreGraphMetadataFor ?g .
> FILTER(?g in (<urn:nepomuk:local:8a9e692a>)) .
> FILTER(
> !bif:exists((select (1) where { graph ?g { ?s ?p ?o . } . }))
> ) .
> } ;
>
> (tested on commercial 06.02.3130 but it should work identically on all
> "version 6" virtuosos as well)
>
> Best Regards,
>
> Ivan Mikhailov
> OpenLink Software
> http://virtuoso.openlinksw.com
>
>
>
> On Wed, 2011-06-29 at 12:41 +0200, Sebastian Trüg wrote:
>> Hi list,
>>
>> With this query:
>>
>> clear graph ?mg where {
>> ?mg nrl:coreGraphMetadataFor ?g .
>> FILTER(?g in (<urn:nepomuk:local:8a9e692a>)) .
>> FILTER(
>> !bif:exists((select (1) where { graph ?g { ?s ?p ?o . } . }))
>> ) .
>> }
>>
>> I get the following error:
>>
>> "SP031: SPARQL compiler: non-global variable 'mg' can not be used
>> outside any group pattern or result-set list"
>>
>> Any idea how to fix this? How to remove graphs which are related to
>> empty graphs the way I am trying in the query?
>>
>> Cheers,
>> Sebastian
>
>
>