如何在 Toad 中避免 DBMS_Output 中的随机换行符
How do I avoid random line-breaks in DBMS_Output, in Toad
我有一个较大的查询,旨在从标准 SQL 数据库生成一个 6MB 'physical' XML 文档(将上传到另一个系统)。
它的尾端看起来像这样:
thisxmltype := dbms_xmldom.getXmlType(domdoc);
dbms_output.enable(null);
print_clob(thisxmltype.getClobVal );
dbms_xmldom.freeDocument(domdoc);
然后我保存 dbms_output 的输出,但是在(每)10,268 个字符之后我发现一个 return 字符,就在 XML 标签名称的中间,或者有时值,这会使整个事情无效。
关于如何避免这种结果的任何建议:
<POSTCODE>EH99 1AA</POSTCODE>
<RE
ASON>99</REASON>
<REASON_OTHER/>
Extract()
和 XMLSERIALIZE
允许您轻松漂亮地打印您的 xmltype:
declare
xdata xmltype:=xmltype('<html><body><p>Hello world.</p></body></html>');
begin
:res_1 := xdata.getclobval();
:res_2 := xdata.extract('/').getclobval();
select XMLSERIALIZE(Document xdata as CLOB INDENT SIZE = 2)
into :res_3
from dual;
end;
/
如您所见,我在此处打印得很漂亮:res_2 和:res_3。
完整示例:
SQL> var res_1 clob;
SQL> var res_2 clob;
SQL> var res_3 clob;
SQL>
SQL> declare
2 xdata xmltype:=xmltype('<html><body><p>Hello world.</p></body></html>');
3 begin
4 :res_1 := xdata.getclobval();
5 :res_2 := xdata.extract('/').getclobval();
6 select XMLSERIALIZE(Document xdata as CLOB INDENT SIZE = 2)
7 into :res_3
8 from dual;
9 end;
10 /
PL/SQL procedure successfully completed.
SQL> col res_1 for a50;
SQL> col res_2 for a50;
SQL> col res_3 for a50;
SQL> print res_1;
RES_1
--------------------------------------------------
<html><body><p>Hello world.</p></body></html>
SQL> print res_2;
RES_2
--------------------------------------------------
<html>
<body>
<p>Hello world.</p>
</body>
</html>
SQL> print res_3;
RES_3
--------------------------------------------------
<html>
<body>
<p>Hello world.</p>
</body>
</html>
我有一个较大的查询,旨在从标准 SQL 数据库生成一个 6MB 'physical' XML 文档(将上传到另一个系统)。 它的尾端看起来像这样:
thisxmltype := dbms_xmldom.getXmlType(domdoc);
dbms_output.enable(null);
print_clob(thisxmltype.getClobVal );
dbms_xmldom.freeDocument(domdoc);
然后我保存 dbms_output 的输出,但是在(每)10,268 个字符之后我发现一个 return 字符,就在 XML 标签名称的中间,或者有时值,这会使整个事情无效。
关于如何避免这种结果的任何建议:
<POSTCODE>EH99 1AA</POSTCODE>
<RE
ASON>99</REASON>
<REASON_OTHER/>
Extract()
和 XMLSERIALIZE
允许您轻松漂亮地打印您的 xmltype:
declare
xdata xmltype:=xmltype('<html><body><p>Hello world.</p></body></html>');
begin
:res_1 := xdata.getclobval();
:res_2 := xdata.extract('/').getclobval();
select XMLSERIALIZE(Document xdata as CLOB INDENT SIZE = 2)
into :res_3
from dual;
end;
/
如您所见,我在此处打印得很漂亮:res_2 和:res_3。
完整示例:
SQL> var res_1 clob;
SQL> var res_2 clob;
SQL> var res_3 clob;
SQL>
SQL> declare
2 xdata xmltype:=xmltype('<html><body><p>Hello world.</p></body></html>');
3 begin
4 :res_1 := xdata.getclobval();
5 :res_2 := xdata.extract('/').getclobval();
6 select XMLSERIALIZE(Document xdata as CLOB INDENT SIZE = 2)
7 into :res_3
8 from dual;
9 end;
10 /
PL/SQL procedure successfully completed.
SQL> col res_1 for a50;
SQL> col res_2 for a50;
SQL> col res_3 for a50;
SQL> print res_1;
RES_1
--------------------------------------------------
<html><body><p>Hello world.</p></body></html>
SQL> print res_2;
RES_2
--------------------------------------------------
<html>
<body>
<p>Hello world.</p>
</body>
</html>
SQL> print res_3;
RES_3
--------------------------------------------------
<html>
<body>
<p>Hello world.</p>
</body>
</html>