Reputation: 1235
I am new to XLQuery and was trying out a basic command-
CREATE TABLE person_data (
person_id NUMBER(3),
person_data XMLTYPE
);
INSERT INTO person_data
(person_id, person_data)
VALUES
(1, XMLTYPE('
<PDRecord>
<PDName>Daniel Morgan</PDName>
<PDDOB>12/1/1951</PDDOB>
<PDEmail>[email protected]</PDEmail>
</PDRecord>')
);
INSERT INTO person_data
(person_id, person_data)
VALUES
(2, XMLTYPE('
<PDRecord>
<PDName>Jack Cline</PDName>
<PDDOB>5/17/1949</PDDOB>
<PDEmail>[email protected]</PDEmail>
</PDRecord>')
);
INSERT INTO person_data
(person_id, person_data)
VALUES
(3, XMLTYPE('
<PDRecord>
<PDName>Caleb Small</PDName>
<PDDOB>1/1/1960</PDDOB>
<PDEmail>[email protected]</PDEmail>
</PDRecord>')
);
What I tried...
select person_id,
XMLQuery('for $i in /PDRecord where $i/PDName = "Jack Cline" order by $i/PDName return $i/PDName'
passing by value t.person_data
returning CONTENT ) XMLData
from person_data t;
But it's failing with error
ORA-30625: method dispatch on NULL SELF argument is disallowed
Not able to understand why? Also if you know some good tutorial for XMlQuery please point me to that.
Note: I have already gone through documentation.
Upvotes: 0
Views: 1413
Reputation: 64949
I suspect that what you are hitting is a bug in LiveSQL.
If we take your query and wrap your call to XMLQuery
in an NVL
which substitutes a dummy document in the null case, we get better output. This query returns successfully, substituting in the dummy document in the case where the condition doesn't match:
select person_id,
NVL(XMLQuery('for $i in /PDRecord where $i/PDName = "Jack Cline" order by $i/PDName return $i/PDName'
passing by value t.person_data
RETURNING CONTENT), XMLTYPE('<empty/>')) XMLData
from person_data t;
There seem to be other bugs in LiveSQL as well: if you take the XMLData
column alias away from the query above, the output gets corrupted.
Upvotes: 1