2011-01-07 18 views

Antwort

2
DBMS_XMLDOM.WRITETOBUFFER Writes the contents of the node to a buffer. 
DBMS_XMLDOM.WRITETOCLOB Writes the contents of the node to a CLOB. 
DBMS_XMLDOM.WRITETOFILE Writes the contents of the node to a file. 

Ich habe PL/SQL-Code, wites es in dem Dateisystem mit einem Verzeichnis:

dbms_xmldom.writeToFile(dbms_xmldom.newDOMDocument(xmldoc) 
             ,'DATAPUMPDIR/myfile.xml') ; 

ich habe eine Funktion dbms_xmldom.writetoclob erstellt

create or replace function xml2clob (xmldoc XMLType) return CLOB is 
    clobdoc CLOB := ' '; 
    begin 
    dbms_xmldom.writeToClob(dbms_xmldom.newDOMDocument(xmldoc) 
             ,clobdoc) ; 
    return clobdoc; 
    end; 
/

Abfrage:

SELECT xml2clob(Sys_Xmlagg(
     Xmlelement(Name "dummy" 
        ,dummy 
        ),Xmlformat('dual'))) 
    FROM dual; 

Ausgang:

<?xml version="1.0"?> 
<dual> 
    <dummy>X</dummy> 
</dual> 

Sie könnten versuchen, eine Funktion wie diese verwenden:

create or replace function dom2clob (domdoc DBMS_XMLDOM.DOMDocument) return CLOB is 
    clobdoc CLOB := ' '; 
    begin 
    dbms_xmldom.writeToClob(domdoc,clobdoc) ; 
    return clobdoc; 
    end; 
/
2

Sie das gleiche erreichen können wie in:

"SELECT xml2clob(Sys_Xmlagg(Xmlelement(Name "dummy",dummy),Xmlformat('dual'))) FROM dual;" 

mit:

und Sie haben nicht die Funktion "xml2clob"

.Extract('/*') ist für "ziemlich Druck"

Ausgabe zu erstellen:

<dual> 
    <dummy>X</dummy> 
</dual> 
0

Wenn Sie bereits ein xmltype haben einfach nutzen die Funktion getClobVal()

xmldoc.getClobVal() 

Dies gibt Ihr X zurück MLType als Clob ohne zusätzlichen Funktionsaufwand.

Verwandte Themen