当字符串连接到EMPTY_CLOB时,解析XML失败

时间:2018-04-11 15:01:30

标签: sql oracle xml-parsing

我有两个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

0 个答案:

没有答案