我正在尝试运行以下sql查询。
SELECT sr.resultid, xt2.*
FROM RESULTS sr,
XMLTABLE('/extraInfo/resultsViewData'
PASSING XMLType(sr.extrainfo)
COLUMNS
docketNumber VARCHAR2(35) PATH 'docketNumber',
dateFiled VARCHAR2(35) PATH 'dateFiled',
nosDescription VARCHAR2(70) PATH 'nosDescription',
courtname VARCHAR2(100) PATH 'courtname',
chapter VARCHAR2(35) PATH 'chapter'
) xt2
WHERE sr.profileId = '7dd76222';
注意:sr.extrainfo
具有值
'<extraInfo><resultsViewData><courtname>FL Circuit & County - Santa Rosa</courtname></resultsViewData></extraInfo>'
即使我使用'& amp ;'
而不是'&'
,我仍然收到以下错误消息,
ORA-31011: XML parsing failed
ORA-19213: error occurred in XML processing at lines 1
LPX-00242: invalid use of ampersand ('&') character (use &)
ORA-06512: at "SYS.XMLTYPE", line 272
ORA-06512: at line 1
31011. 00000 - "XML parsing failed"
*Cause: XML parser returned an error while trying to parse the document.
*Action: Check if the document to be parsed is valid.
有时候我什至会收到错误消息,
LPX-00242: invalid use of ampersand ('&') character (use &amp;)
有什么办法可以解决这个问题?
答案 0 :(得分:1)
尝试:
set define off;
然后执行查询;
如果您想了解有关set define off;
所做的更多信息:When or Why to use a "SET DEFINE OFF" in Oracle Database
答案 1 :(得分:0)
我一开始无法重现您的问题。
但是如果仍然遇到问题,请尝试使用dbms_xmlgen.convert
如下转换字符串:
'<extraInfo><resultsViewData><courtname>'
|| dbms_xmlgen.convert('FL Circuit & County - Santa Rosa')
|| '</courtname></resultsViewData></extraInfo>'
干杯!