加入收藏 | 设为首页 | 会员中心 | 我要投稿 辽源站长网 (https://www.0437zz.com/)- 云专线、云连接、智能数据、边缘计算、数据安全!
当前位置: 首页 > 站长百科 > 正文

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

发布时间:2021-01-02 12:35:17 所属栏目:站长百科 来源:网络整理
导读:运行Oracle 10g,Sqldeveloper 1.5.5 我想在sqldeveloper的输出或结果窗口中以字符串形式查看DBMS_XMLDOM.DOMDocument的内容.或者其他一些调试这个东西的简单方法…… 谢谢,P 解决方法 DBMS_XMLDOM.WRITETOBUFFER Writes the contents of the node to a buffe

运行Oracle 10g,Sqldeveloper 1.5.5

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

谢谢,P

解决方法

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.

我有PL / SQL代码,它使用DIRECTORY将它连接到文件系统:

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

我使用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;
   /

查询:

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

输出:

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

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

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

(编辑:辽源站长网)

【声明】本站内容均来自网络,其相关言论仅代表作者个人观点,不代表本站立场。若无意侵犯到您的权利,请及时与联系站长删除相关内容!

    推荐文章
      热点阅读