2016-07-22 81 views
1

请参阅下面的SQL:生成XML - 排除节点

select dbms_xmlgen.getxml('select incident_id FROM INCIDENTS where incident_id=600') xml 
from dual 

它返回:

<?xml version="1.0"?> 
<ROWSET> 
<ROW> 
    <INCIDENT_ID>600</INCIDENT_ID> 
</ROW> 
</ROWSET> 

,如何排除返回此:

<SYSTEM URN="114644"> 
<INCIDENT_ID>600</INCIDENT_ID> 
<SYSTEM> 

我想硬编码XML的第一行和第三行。

回答

1

使用提取函数来获得所需输出

EXTRACT (XML) is similar to the EXISTSNODE function. 
It applies a VARCHAR2 XPath string and returns an XMLType instance containing an XML fragment. You can specify an absolute XPath_string with an initial slash or a relative XPath_string by omitting the initial slash. 
If you omit the initial slash, the context of the relative path defaults to the root node... 

在此还看到类似的问题 https://community.oracle.com/thread/1126429?tstart=0

+1

我编辑了问题。你可以看一下吗?谢谢。 – w0051977

+0

所以你可以连接硬编码的字符串,如[SELECT''||]。其他XML部分在这里|| ''从XYZ ...] – user648026