9 Replies Latest reply on Sep 23, 2010 9:57 AM by 799283

    Getting ORA-00904 from various SPARQL statements

    799283
      Hi,

      I am currently working on a couple of Java services which offer access to semantic information using Jena. I have implemented two possible adapters so far, one "feeds" from an owl-file directly, one from an Oracle 11g (semantic technologies).

      In both cases, I use SPARQL SELECT and CONSTRUCT statements for my queries. Querying the owl-file-based adapter with these statements, everything works fine. querying the Oracle adapter, I often get the following stacktrace:

      Caused by: java.sql.SQLException: ORA-00904: "TYPE": ungültiger Bezeichner

           at oracle.jdbc.driver.SQLStateMapping.newSQLException(SQLStateMapping.java:74)
           at oracle.jdbc.driver.DatabaseError.newSQLException(DatabaseError.java:131)
           at oracle.jdbc.driver.DatabaseError.throwSqlException(DatabaseError.java:204)
           at oracle.jdbc.driver.T4CTTIoer.processError(T4CTTIoer.java:455)
           at oracle.jdbc.driver.T4CTTIoer.processError(T4CTTIoer.java:413)
           at oracle.jdbc.driver.T4C8Oall.receive(T4C8Oall.java:1034)
           at oracle.jdbc.driver.T4CPreparedStatement.doOall8(T4CPreparedStatement.java:194)
           at oracle.jdbc.driver.T4CPreparedStatement.executeForDescribe(T4CPreparedStatement.java:791)
           at oracle.jdbc.driver.T4CPreparedStatement.executeMaybeDescribe(T4CPreparedStatement.java:866)
           at oracle.jdbc.driver.OracleStatement.doExecuteWithTimeout(OracleStatement.java:1186)
           at oracle.jdbc.driver.OraclePreparedStatement.executeInternal(OraclePreparedStatement.java:3387)
           at oracle.jdbc.driver.OraclePreparedStatement.executeQuery(OraclePreparedStatement.java:3431)
           at oracle.jdbc.driver.OraclePreparedStatementWrapper.executeQuery(OraclePreparedStatementWrapper.java:1203)
           at oracle.spatial.rdf.client.jena.Oracle.executeQuery(Oracle.java:352)
           at oracle.spatial.rdf.client.jena.Oracle.executeQuery(Oracle.java:315)
           at oracle.spatial.rdf.client.jena.OracleSemQueryPlan.executeBindings(OracleSemQueryPlan.java:431)
           ... 65 more


      The SELECT statement used is:

      ==============
      PREFIX owl: <http://www.w3.org/2002/07/owl#>
      PREFIX rdf: <http://www.w3.org/1999/02/22-rdf-syntax-ns#>
      PREFIX rdfs: <http://www.w3.org/2000/01/rdf-schema#>
      SELECT DISTINCT ?type ?label ?comment
      WHERE { <http://www.demo-uri.com/test.owl#demoInstance> rdf:type ?type .
      OPTIONAL { <http://www.demo-uri.com/test.owl#demoInstance> rdfs:label ?label .
      FILTER(langMatches(lang(?label),'de') || (!langMatches(lang(?label),'*'))) . }
      OPTIONAL { <http://www.demo-uri.com/test.owl#demoInstance> rdfs:comment ?comment .
      FILTER(langMatches(lang(?comment),'de') || (!langMatches(lang(?comment),'*'))) }
      }
      ==============

      The generated SELECT clause is:

      SELECT type$RDFVTYP, type$RDFLTYP, type$RDFLANG, type$RDFCLOB, decode(type$RDFVTYP, 'BLN', ('_:'||substr(type,instr(type,'m',4)+1)), type) type
      FROM table(sdo_rdf_match('(<http://www.demo-uri.com/test.owl#demoInstance> <http://www.w3.org/1999/02/22-rdf-syntax-ns#type> ?type) ', sdo_rdf_models('DEMO_MODEL'), sdo_rdf_rulebases('OWLPRIME'), null, null, NULL,' '))



      I am really grateful for any advise! A simple statement like

      [...]WHERE { <http://www.demo-uri.com/test.owl#demoInstance> rdf:type ?type }

      works fine.

      Best,

      Damian
        • 1. Re: Getting ORA-00904 from various SPARQL statements
          Matperry-Oracle
          Hi,

          The problem is likely from the variable ?comment. 'comment' is a reserved word in Oracle. Please try using a different variable name.

          Thanks,
          Matt
          • 2. Re: Getting ORA-00904 from various SPARQL statements
            799283
            Hey Matt,

            thanks for the advice. Unfortunately, that does not solve my problem. I have already tried to use random variable names :( Do you have any other ideas?

            Best,
            Damian
            • 3. Re: Getting ORA-00904 from various SPARQL statements
              Sdas-Oracle
              Please try the query after making the following two changes:

              1) change the variable name ?comment to something different such as ?cmnt, AND

              2) use double-quotes (instead of single-quotes) to enclose the language-range: that is,
              - replace all occurrences of 'de' with "de" AND
              - replace all occurrences of '*' with "*"

              Thanks.
              • 4. Re: Getting ORA-00904 from various SPARQL statements
                799283
                Thanks for the reply.

                I have changed the statement according to your advice:

                PREFIX owl: <http://www.w3.org/2002/07/owl#>
                PREFIX rdf: <http://www.w3.org/1999/02/22-rdf-syntax-ns#>
                PREFIX rdfs: <http://www.w3.org/2000/01/rdf-schema#>
                SELECT DISTINCT ?typ ?lbl ?cmnt
                WHERE { <http://www.demo-uri.com/test.owl#demoInstance> rdf:type ?typ .
                OPTIONAL { <http://www.demo-uri.com/test.owl#demoInstance> rdfs:label ?lbl .
                FILTER(langMatches(lang(?lbl),"de") || (!langMatches(lang(?lbl),"*"))) . }
                OPTIONAL { <http://www.demo-uri.com/test.owl#demoInstance> rdfs:comment ?cmnt .
                FILTER(langMatches(lang(?cmnt),"de") || (!langMatches(lang(?cmnt),"*"))) }}

                but still the same stacktrace :(

                Caused by: java.sql.SQLException: ORA-00904: "TYP": ungültiger Bezeichner

                     at oracle.jdbc.driver.SQLStateMapping.newSQLException(SQLStateMapping.java:74)
                     at oracle.jdbc.driver.DatabaseError.newSQLException(DatabaseError.java:131)
                     at oracle.jdbc.driver.DatabaseError.throwSqlException(DatabaseError.java:204)
                     at oracle.jdbc.driver.T4CTTIoer.processError(T4CTTIoer.java:455)
                     at oracle.jdbc.driver.T4CTTIoer.processError(T4CTTIoer.java:413)
                     at oracle.jdbc.driver.T4C8Oall.receive(T4C8Oall.java:1034)
                     at oracle.jdbc.driver.T4CPreparedStatement.doOall8(T4CPreparedStatement.java:194)
                     at oracle.jdbc.driver.T4CPreparedStatement.executeForDescribe(T4CPreparedStatement.java:791)
                     at oracle.jdbc.driver.T4CPreparedStatement.executeMaybeDescribe(T4CPreparedStatement.java:866)
                     at oracle.jdbc.driver.OracleStatement.doExecuteWithTimeout(OracleStatement.java:1186)
                     at oracle.jdbc.driver.OraclePreparedStatement.executeInternal(OraclePreparedStatement.java:3387)
                     at oracle.jdbc.driver.OraclePreparedStatement.executeQuery(OraclePreparedStatement.java:3431)
                     at oracle.jdbc.driver.OraclePreparedStatementWrapper.executeQuery(OraclePreparedStatementWrapper.java:1203)
                     at oracle.spatial.rdf.client.jena.Oracle.executeQuery(Oracle.java:352)
                     at oracle.spatial.rdf.client.jena.Oracle.executeQuery(Oracle.java:315)
                     at oracle.spatial.rdf.client.jena.OracleSemQueryPlan.executeBindings(OracleSemQueryPlan.java:431)
                     ... 65 more

                Edited by: user13170651 on 22.09.2010 02:32
                • 5. Re: Getting ORA-00904 from various SPARQL statements
                  799283
                  Another possibly important information I forgot zu add:

                  If I delete the FILTERs, the error is gone. So I suppose the error must be somehow related to the FILTER elements of the statement.

                  Also CONSTRUCT statements are affected, like this one:

                  CONSTRUCT { ?s ?p <http://www.owl-ontologies.com/Ontology1283425506.owl#testConcept>}
                  WHERE {
                  { ?s ?p <http://www.owl-ontologies.com/Ontology1283425506.owl#testConcept>}
                  FILTER (?p != <http://www.w3.org/2000/01/rdf-schema#domain>)
                  FILTER (?p != <http://www.w3.org/2000/01/rdf-schema#range>)}

                  Same error: Caused by: java.sql.SQLException: ORA-00904: "P": ungültiger Bezeichner (means: invalid identifier)

                  :(

                  Any more ideas?

                  Best,
                  Damian
                  • 6. Re: Getting ORA-00904 from various SPARQL statements
                    Sdas-Oracle
                    Could you please try the following equivalent query directly from SQL*plus (instead of coming thru Java)? (Assuming 'DEMO_MODEL' is the name of the target RDF model and there is an OWLPRIME entailment for it.)

                    SELECT DISTINCT typ, lbl, cmnt FROM TABLE(SEM_MATCH('
                    { <http://www.demo-uri.com/test.owl#demoInstance> rdf:type ?typ .
                    OPTIONAL { <http://www.demo-uri.com/test.owl#demoInstance> rdfs:label ?lbl .
                    FILTER(langMatches(lang(?lbl),"de") || (!langMatches(lang(?lbl),"*"))) . }
                    OPTIONAL { <http://www.demo-uri.com/test.owl#demoInstance> rdfs:comment ?cmnt .
                    FILTER(langMatches(lang(?cmnt),"de") || (!langMatches(lang(?cmnt),"*"))) }}
                    '
                    , sdo_rdf_models('DEMO_MODEL'), sdo_rdf_rulebases('OWLPRIME'), null, null
                    ));

                    Thanks.
                    • 7. Re: Getting ORA-00904 from various SPARQL statements
                      799283
                      Hi,

                      I have just tried that. I have used DB Visualizer, I hope that is OK. The result is the same however:

                      15:15:54 [SELECT - 0 row(s), 0.000 secs] [Error Code: 904, SQL State: 42000] ORA-00904: "CMNT": ungültiger Bezeichner
                      ... 1 statement(s) executed, 0 row(s) affected, exec/fetch time: 0.000/0.000 sec [0 successful, 0 warnings, 1 errors]

                      How can I check on the existence of the OWLPRIME entailment?
                      • 8. Re: Getting ORA-00904 from various SPARQL statements
                        Matperry-Oracle
                        Hi,

                        We can't seem to reproduce your problem. Please contact me directly at matthew dot perry at oracle dot com so that I can get some more detailed information about your setup.

                        Thanks,
                        Matt
                        • 9. Re: Getting ORA-00904 from various SPARQL statements
                          799283
                          Matt,

                          thanks for the offer - but it currently looks as if we have found the error. I do not have all the details yet, but our DBA has found some inconsistencies in the 11g setup - it seems that something has gone wrong during the migration from an earlier version.

                          I have tried my statements with another instance of the database and everything seems to work fine! :)

                          Thanks for all your help!!!

                          Best,
                          Damian