SPARQL With FILTER Containing Two Alternative Conditions Returns Incorrect Result (Doc ID 1560869.1)

Last updated on FEBRUARY 08, 2017

Applies to:

Oracle Spatial - Version 11.2.0.3 and later
Information in this document applies to any platform.

Symptoms

FILTER with two alternative conditions.
The first condition uses a variable from a subquery.

The first query "filterLogicalOr.txt" seems to incorrectly return only triples that satisfy the second part of the filter criteria FILTER(?sumStilling = 0 || ?permisjonskode = "FODSEL").
If instead of binding the evaluation of the logical-or to a new variable and filter on the that variable, the query returns the expected results, i.e. any result where ?sumStilling = 0 OR ?permisjonskode = “FODSEL”. This can be seen in the query "filterBoundLogicalOr.txt".
 
"filterLogicalOr.txt":
----------------------
PREFIX fim: <http://nav.no/organisasjon/vocab/>
PREFIX xsd: <http://www.w3.org/2001/XMLSchema#>
PREFIX ORACLE_SEM_FS_NS: <http://oracle.com/semtech#midtier_cache,timeout=300>

CONSTRUCT {
  ?ressurs fim:permisjonTil ?nermesteDato ;
  fim:permisjonskode ?permisjonskode ;
  fim:prosent ?sumStilling .
 }
WHERE {

  {SELECT ?ressurs (SUM(xsd:decimal(?stillingsprosent)) AS ?sumStilling ) (MIN(?tomdato) AS ?nermesteDato)
  where {
  ?ressurs a fim:Ressurs ;
  fim:erTilknyttetVia ?stilling.

  ?stilling a fim:Stilling;
  fim:stillingsprosent ?stillingsprosent;
  fim:gyldighetsperiode / fim:tom ?tomdato .
  }
  GROUP BY ?ressurs
  }

?ressurs fim:erTilknyttetVia ?stilling.

?stilling a fim:Stilling;
  fim:harFravaer / fim:permisjonskode / fim:navn ?permisjonskode ;
fim:gyldighetsperiode / fim:tom ?nermesteDato .

FILTER(?sumStilling = 0 || ?permisjonskode = "FODSEL")
}



<rdf:RDF
  xmlns:ORACLE_SEM_FS_NS="http://oracle.com/semtech#midtier_cache,timeout=300"
  xmlns:rdf="http://www.w3.org/1999/02/22-rdf-syntax-ns#"
  xmlns:fim="http://nav.no/organisasjon/vocab/"
  xmlns:xsd="http://www.w3.org/2001/XMLSchema#">
  
    >200
  FODSEL
  2013-08-31T00:00:00
...
...
  
  2013-07-22T00:00:00
  FODSEL
    >200
  


"filterBoundLogicalOr.txt":
---------------------------
PREFIX fim: <http://nav.no/organisasjon/vocab/>
PREFIX xsd: <http://www.w3.org/2001/XMLSchema#>
PREFIX ORACLE_SEM_FS_NS: <http://oracle.com/semtech#midtier_cache,timeout=300>

CONSTRUCT {
  ?ressurs fim:permisjonTil ?nermesteDato ;
  fim:permisjonskode ?permisjonskode ;
  fim:prosent ?sumStilling .
 }
WHERE {

  {SELECT ?ressurs (SUM(xsd:decimal(?stillingsprosent)) AS ?sumStilling ) (MIN(?tomdato) AS ?nermesteDato)
  where {
  ?ressurs a fim:Ressurs ;
  fim:erTilknyttetVia ?stilling.

  ?stilling a fim:Stilling;
  fim:stillingsprosent ?stillingsprosent;
  fim:gyldighetsperiode / fim:tom ?tomdato .
  }
  GROUP BY ?ressurs
  }

?ressurs fim:erTilknyttetVia ?stilling.

?stilling a fim:Stilling;
  fim:harFravaer / fim:permisjonskode / fim:navn ?permisjonskode ;
fim:gyldighetsperiode / fim:tom ?nermesteDato .

BIND((?sumStilling = 0 || ?permisjonskode = "FODSEL") as ?flag)
FILTER (?flag)
}




<rdf:RDF
  xmlns:ORACLE_SEM_FS_NS="http://oracle.com/semtech#midtier_cache,timeout=300"
  xmlns:rdf="http://www.w3.org/1999/02/22-rdf-syntax-ns#"
  xmlns:fim="http://nav.no/organisasjon/vocab/"
  xmlns:xsd="http://www.w3.org/2001/XMLSchema#">
  
    >200
  FODSEL
  2013-08-31T00:00:00
...
...
  
  2013-08-31T00:00:00
  ULØNN-OMSORG
    >0
  


Cause

Sign In with your My Oracle Support account

Don't have a My Oracle Support account? Click to get started

My Oracle Support provides customers with access to over a
Million Knowledge Articles and hundreds of Community platforms