8 Replies Latest reply on Aug 10, 2011 6:40 AM by 880207

    Can we have SQL Query's IN Clause in SPARQL

    880207
      Hi ,

      I want to do something similar to our SQL Query's IN Clause in SPARQL.
      SQL Example :

      select employeeName where empid IN ('1','2','3');

      Can we do something similar in SPARQL?

      Thanks and Regards,
      Manish Hardasmalani
        • 1. Re: Can we have SQL Query's IN Clause in SPARQL
          alwu-Oracle
          Hi Manish,

          Can a SPARQL filter with "logical or" do the trick for you?

          As an alternative, you can refer to Section 7.6.2 of the following document.
          http://download.oracle.com/docs/cd/E16338_01/appdev.112/e11828.pdf

          Thanks,

          Zhe Wu
          • 2. Re: Can we have SQL Query's IN Clause in SPARQL
            880207
            Hi Zhe,

            Thanks for the pdf link you shared. I got my correct results.
            Not sure, the use of PREFIX ORACLE_SEM_FS_NS: <http://oracle.com/semtech#no_fall_back,s2s>
            I didn't use this prefix and got my results :)
            when i used this prefix i got below error :

            com.hp.hpl.jena.shared.JenaException: oracle.spatial.rdf.client.jena.NoEntailmentException: processSqlException: ORA-00942: table or view does not exist

                 at oracle.spatial.rdf.client.jena.OracleRepeatApply.nextStage(OracleRepeatApply.java:902)
                 at com.hp.hpl.jena.sparql.engine.iterator.QueryIterRepeatApply.makeNextStage(QueryIterRepeatApply.java:94)
                 at com.hp.hpl.jena.sparql.engine.iterator.QueryIterRepeatApply.hasNextBinding(QueryIterRepeatApply.java:55)
                 at com.hp.hpl.jena.sparql.engine.iterator.QueryIteratorBase.hasNext(QueryIteratorBase.java:69)
                 at com.hp.hpl.jena.sparql.engine.iterator.QueryIteratorWrapper.hasNextBinding(QueryIteratorWrapper.java:31)
                 at com.hp.hpl.jena.sparql.engine.iterator.QueryIteratorBase.hasNext(QueryIteratorBase.java:69)
                 at com.hp.hpl.jena.sparql.engine.iterator.QueryIteratorWrapper.hasNextBinding(QueryIteratorWrapper.java:31)
                 at com.hp.hpl.jena.sparql.engine.iterator.QueryIteratorBase.hasNext(QueryIteratorBase.java:69)
                 at com.hp.hpl.jena.sparql.engine.ResultSetStream.hasNext(ResultSetStream.java:63)
                 at com.hp.hpl.jena.sparql.resultset.ResultSetMem.<init>(ResultSetMem.java:85)
                 at com.hp.hpl.jena.sparql.resultset.TextOutput.write(TextOutput.java:135)
                 at com.hp.hpl.jena.sparql.resultset.TextOutput.write(TextOutput.java:118)
                 at com.hp.hpl.jena.sparql.resultset.TextOutput.write(TextOutput.java:106)
                 at com.hp.hpl.jena.sparql.resultset.TextOutput.format(TextOutput.java:53)
                 at com.hp.hpl.jena.query.ResultSetFormatter.out(ResultSetFormatter.java:112)
                 at JenaSparqlSelect.main(JenaSparqlSelect.java:152)
            Caused by: oracle.spatial.rdf.client.jena.NoEntailmentException: processSqlException: ORA-00942: table or view does not exist

                 at oracle.spatial.rdf.client.jena.GraphOracleSem.processSqlExceptionAfterQueryExecution(GraphOracleSem.java:2642)
                 at oracle.spatial.rdf.client.jena.OracleOpExecutor.buildSemIterator(OracleOpExecutor.java:1914)
                 at oracle.spatial.rdf.client.jena.OracleRepeatApply.nextStage(OracleRepeatApply.java:857)
                 ... 15 more
            • 3. Re: Can we have SQL Query's IN Clause in SPARQL
              alwu-Oracle
              Hi,

              That error message means that you don't have a valid entailment. Did you run performInference?

              Thanks,

              Zhe Wu
              • 4. Re: Can we have SQL Query's IN Clause in SPARQL
                880207
                Hi Zhe,

                No i didnt not run performInference. Is it necessary to run it? if yes, how can i do that.

                Thanks and Regards,
                Manish Hardasmalani
                • 5. Re: Can we have SQL Query's IN Clause in SPARQL
                  alwu-Oracle
                  Hi Manish,

                  How did you create GraphOracleSem? Did you use Attachment with a rulebase?

                  Thanks,

                  Zhe
                  • 6. Re: Can we have SQL Query's IN Clause in SPARQL
                    880207
                    Hi Zhe,

                    Yes i have used Attachement for adding my Models and Rulebases to GraphOracleSem.

                    Attachment attachment = Attachment.createInstance( new String[] {}, "RDFS", InferenceMaintenanceMode.NO_UPDATE, QueryOptions.DEFAULT);
                    GraphOracleSem graph = new GraphOracleSem(oracle, MODEL_NAME, attachment);

                    do i need to call performInference after this? if yes, can i know the reason.

                    Thanks and Regards,
                    Manish Hardasmalani
                    • 7. Re: Can we have SQL Query's IN Clause in SPARQL
                      alwu-Oracle
                      Yes. Oracle's inference engine is forward chaining based. You need to invoke performInference to calculate the entailment.

                      Thanks,

                      Zhe
                      • 8. Re: Can we have SQL Query's IN Clause in SPARQL
                        880207
                        Hi Zhe,

                        I invoked performinference and uncommented below prefix from my query, It worked perfectly fine.

                        "PREFIX ORACLE_SEM_FS_NS: <http://oracle.com/semtech#no_fall_back,s2s>

                        Thanks and Regards,
                        Manish H