This discussion is archived
5 Replies Latest reply: May 23, 2012 6:50 AM by matperry RSS

submit sparql using sqlplus

681909 Newbie
Currently Being Moderated
I want to run a sparql query using sqlplus. I got something real simple to work fine like:

select s,typ from table(sem_match('(?s rdf:type ?typ)', sem_models('cnodb'), null, null, null))

However, I get errors when the sparql is a bit more complex like this:

select subj,rel,obj from table(sem_match('(?s rdf:object ?obj . ?s rdf:subject ?subj . ?s dc:relation ?rel)', sem_models('cnodb'), null, null, null))

ERROR at line 1:
ORA-29532: Java call terminated by uncaught Java exception:
oracle.spatial.rdf.server.ParseException: Encountered "." at line 1, column 21.
Was expecting:
")" ...
ORA-06512: at "MDSYS.RDF_MATCH_IMPL_T", line 203
ORA-06512: at "MDSYS.RDF_MATCH_IMPL_T", line 67
ORA-06512: at line 4

Does anyone know the proper syntax to submit this sparql? Thanks.

Russ
  • 1. Re: submit sparql using sqlplus
    matperry Journeyer
    Currently Being Moderated
    Hi,

    Two types of syntax are supported: (1) parenthesis and (2) curly brace.

    Your query with parenthesis syntax would be:

    select subj,rel,obj from table(sem_match('(?s rdf:object ?obj) (?s rdf:subject ?subj) (?s dc:relation ?rel)', sem_models('cnodb'), null, null, null))

    With curly-brace syntax it would be:

    select subj,rel,obj from table(sem_match('{ ?s rdf:object ?obj . ?s rdf:subject ?subj . ?s dc:relation ?rel }', sem_models('cnodb'), null, null, null))

    UNION and FILTER keywords are only supported in the curly-brace syntax. You can see the documentation describing SEM_MATCH for more detailed information: http://download.oracle.com/docs/cd/E11882_01/appdev.112/e11828/sdo_rdf_concepts.htm#CHDJACII

    Hope this helps.
  • 2. Re: submit sparql using sqlplus
    638832 Newbie
    Currently Being Moderated
    Helllo,

    Is there possible to run SPARQL querys on Oracle.....I know that is possible to run SQL querys, for example: select s,p,o from table(SEM_MATCH('(?s ?p ?o)', SEM_Models('articles'), null, null, null )); .....but how about pure SPARQL querys?

    Thank you.
    Catalin
  • 3. Re: submit sparql using sqlplus
    matperry Journeyer
    Currently Being Moderated
    Hi,

    Pure SPARQL syntax is not supported through SQL*Plus. However, using Jena Adapter for Oracle Database (available here: http://www.oracle.com/technology/software/tech/semantic_technologies/index.html), you can execute pure SPARQL queries through a Java API, or you can set up a SPARQL endpoint.

    More information about Jena Adapter can be found here: http://download.oracle.com/docs/cd/E11882_01/appdev.112/e11828/sem_jena.htm#CBBJJJJB
  • 4. Re: submit sparql using sqlplus
    810416 Newbie
    Currently Being Moderated
    I can run queries with paranthesis syntax.
    However, when I run the following query:

    select scan_num, rt from table(sem_match(
    '{ ?s rdf:type owl:scan.
    ?s owl:_num ?scan_num.
    ?s owl:_retentionTime ?rt. }',
    sem_models('final1'), null,SEM_ALIASES(SEM_ALIAS('owl','http://www.owl-ontologies.com/mzxml.owl#')),null,null,null));

    I get following results:
    select scan_num, rt from table(sem_match(
    *
    ERROR at line 1:
    ORA-29532: Java call terminated by uncaught Java exception:
    oracle.spatial.rdf.server.ParseException: Encountered "?s" at line 2, column 4.
    Was expecting one of:
    "OPTIONAL" ...
    "FILTER" ...
    "{" ...
    "." ...
    "}" ...
    ORA-06512: at "MDSYS.RDF_MATCH_IMPL_T", line 203
    ORA-06512: at "MDSYS.RDF_MATCH_IMPL_T", line 67
    ORA-06512: at line 4


    Elapsed: 00:00:00.05
    sqlplus OK


    May I know what the error could be?
  • 5. Re: submit sparql using sqlplus
    matperry Journeyer
    Currently Being Moderated
    Hi,

    You have encountered a known parser bug with version 11.2.0.1.0. The '.' character that ends a triple pattern has been incorrectly appended to the object of the triple pattern. You can work around this bug by adding a space between the object and the '.' character.

    For example, change

    select scan_num, rt from table(sem_match(
    '{ ?s rdf:type owl:scan.
    ?s owl:_num ?scan_num.
    ?s owl:_retentionTime ?rt. }',
    sem_models('final1'), null,SEM_ALIASES(SEM_ALIAS('owl','http://www.owl-ontologies.com/mzxml.owl#')),null,null,null));

    to

    select scan_num, rt from table(sem_match(
    '{ ?s rdf:type owl:scan .
    ?s owl:_num ?scan_num .
    ?s owl:_retentionTime ?rt . }',
    sem_models('final1'), null,SEM_ALIASES(SEM_ALIAS('owl','http://www.owl-ontologies.com/mzxml.owl#')),null,null,null));

    This bug has been fixed in version 11.2.0.2.0 and later.

Legend

  • Correct Answers - 10 points
  • Helpful Answers - 5 points