dbms_output超长问题

来源:互联网 发布:python crypto安装 编辑:程序博客网 时间:2024/04/29 04:39
关于10g以下dbms_output.put_line超长的问题

对于10gdbms_output.put_line的长度是没有限制
如果报错:buffer overflow,执行如下语句即可:
set serveroutput ON SIZE UNLIMITED FORMAT WORD_WRAPPED
由于10g以下dbms_output.put_line的长度有限制
所以今天特意写了一个按照回车符来截取字符串,也就是按行截取,然后打印出来的过程,希望对某些人有用!


create or replace procedure print_proc(str in varchar2) is
/*
--打印字符串,调试的时候用
--由于字符串过长,超过了dbms_output.put_line的长度,故采用本程序分行打印出来
--@auther:Z.X.T
--@date:2007-6-26
*/
begin
dbms_output.put_line('lengthb(str) =' || lengthb(str));
if (lengthb(str) < 255) then
dbms_output.put_line(str);
else
for i in 1 .. length(str) - length(replace(str, chr(10))) + 1
loop
dbms_output.put_line(substr(str, instr(chr(10) || str, chr(10), 1, i), instr(str ||
chr(10), chr(10), 1, i) -
instr(chr(10) || str, chr(10), 1, i)));
end loop;
end if;
exception
when others then
dbms_output.put_line(sqlerrm);
dbms_output.put_line(dbms_utility.format_call_stack);
end print_proc;