4

使用 Oracle 11,当我这样做时

  SELECT XMLELEMENT("dummy", NULL) as xml_1 
    FROM dual

输出是<dummy></dummy>

我怎样才能强制返回 <dummy />

4

1 回答 1

6

is this just for presentation purposes, as both are the same. Oracle's function just happen to return non short tag style.

xmltype constructor though will convert it on 11g (in 10g the extract function did too, but not in 11g).

SQL> SELECT xmltype(XMLELEMENT("dummy", NULL).getclobval()) as xml_1 from dual;

XML_1
--------------------------------------------------------------------------------
<dummy/>
于 2013-01-11T10:48:36.570 回答