I was trying to explore the semantic features of Oracle Database by running a semantic related sql on a semantic model I created in Oracle. But I can’t make it work, and there are little information about this.
The function of the procedure is simple, to get the result set from the sparql query.
CREATE OR REPLACE PROCEDURE PROC_MERGE_PATHWAY_SEM AS
TYPE c_type IS REF CURSOR;
semCursor c_type;
p1 VARCHAR2(40);
p2 VARCHAR2(40);
interCount INTEGER;
BEGIN
OPEN semCursor FOR
'SELECT p1, p2, COUNT(g) as interCount
FROM TABLE (sem_match (
"{?p1 <http://example.com/test.owl#relates_to> ?g . ?p2 <http://example.com/test.owl#relates_to> ?g }",
sem_models("pathway"),
null,
null,
null))';
LOOP
FETCH semCursor INTO p1, p2, interCount;
EXIT WHEN semCursor%NOTFOUND;
DBMS_OUTPUT.PUT_LINE(p1||','||p2||','||interCount);
END LOOP;
/*
FOR records IN semCursor LOOP
DBMS_OUTPUT.PUT_LINE('test');
END LOOP; */
END PROC_MERGE_PATHWAY_SEM;
Compiling errors are as follow:
ORA-00972: identifier is too long
ORA-06512: at “SYSTEM.PROC_MERGE_PATHWAY_SEM”, line 9
ORA-06512: at line 2
I’m not sure if it is caused by sem_match syntax error wrapped by cursor statement, or a bug in Oracle 11g2? Could someone help me with this? Thanks.
You appear to be using double quotes (
") in thesem_matchcall, where I think you should be using two single quotes (''); which you need because it’s already inside single quotes from theopen ... for.(I should maybe note that I’ve never used semantics, but the docs indicate single quotes).
The double quotes are causing the whole string within them to be treated as a literal identifier, hence the error message.
But as Mat commented, you don’t need the single quotes around the
select, so you don’t need to escape those in thesem_match.Updated following comments: Assuming you do need the whole
selectwrapped in single quotes as the article you linked to suggests, the single quotes that were already inside the command need to be escaped, which in Oracle is done by using two single quotes together (''); in the article that looked rather like a double quote (") instead so I can understand your confusion. Based on the code you put in paste bin:Each of the
"you had in your query in the original question is replaced by two single quotes, sosem_models("pathway")becomessem_models(''pathway'').