2016-07-22 18 views
1

Bitte beachten Sie die SQL unten:XML generieren - Knoten ausschließen

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

Es gibt:

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

Wie kann ich das ausschließen zurück:

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

Ich möchte, dass die hart codieren erste Zeile und dritte Zeile des XML.

Antwort

1

Verwenden Extrakt Funktion Ihre gewünschte Ausgabe

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... 

auch sehen ähnliche Frage bekommen hier https://community.oracle.com/thread/1126429?tstart=0

+1

ich die Frage bearbeitet haben. Könnten Sie einen Blick darauf werfen? Vielen Dank. – w0051977

+0

So können Sie die hart codierte Zeichenfolge ähnlich wie [SELECT '' || verketten Andere XML-Teile hier || '' VON XYZ ...] – user648026