Oracle:如何显示 DBMS_XMLDOM.DOMDocument 以进行调试?

Pet*_*ras 3 oracle xmldom

运行 Oracle 10g,Sqldeveloper 1.5.5

我想在 sqldeveloper 的输出或结果窗口中以字符串形式查看 DBMS_XMLDOM.DOMDocument 的内容。或其他一些简单的方法来调试这个东西......

谢谢,P

Rob*_*ebe 5

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.
Run Code Online (Sandbox Code Playgroud)

我有使用目录将它写入文件系统的 PL/SQL 代码:

   dbms_xmldom.writeToFile(dbms_xmldom.newDOMDocument( xmldoc)
                                       ,'DATAPUMPDIR/myfile.xml') ;
Run Code Online (Sandbox Code Playgroud)

我使用 dbms_xmldom.writetoclob 创建了一个函数

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

询问:

SELECT xml2clob(Sys_Xmlagg(
         Xmlelement(Name "dummy"
                   ,dummy
                   ),Xmlformat('dual')))
   FROM dual;
Run Code Online (Sandbox Code Playgroud)

输出:

<?xml version="1.0"?>
<dual>
  <dummy>X</dummy>
</dual>
Run Code Online (Sandbox Code Playgroud)

您可以尝试使用这样的函数:

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