我有两个XML字符串都插入CLOB
列。第一个是文本文字,第二个是与文本文字连接的EMPTY_CLOB()
。
为什么Oracle在CLOB
连接时无法解析EMPTY_CLOB()
?
MCVE: SQL Fiddle
Oracle 11g R2架构设置:
CREATE TABLE test ( id NUMBER(2,0), xml_str CLOB );
INSERT INTO test VALUES ( 1, '<a>1</a>' );
INSERT INTO test VALUES ( 2, EMPTY_CLOB() || '<a>2</a>' );
查询1 :
SELECT id, a
FROM test t
CROSS JOIN
XMLTABLE(
'/a'
PASSING XMLType( t.xml_str )
COLUMNS
a NUMBER(2,0) PATH '.'
) x
WHERE id = 1
Results :
| ID | A |
|----|---|
| 1 | 1 |
查询2 :
SELECT id, a
FROM test t
CROSS JOIN
XMLTABLE(
'/a'
PASSING XMLType( t.xml_str )
COLUMNS
a NUMBER(2,0) PATH '.'
) x
WHERE id = 2
Results :
ORA-31011: XML parsing failed ORA-19202: Error occurred in XML processing LPX-00007: unexpected end-of-file encountered ORA-06512: at "SYS.XMLTYPE", line 272 ORA-06512: at line 1