oracle pl/sql bug: can't put_line more than 2000 characters

Posted by FrustratedWithFormsDesigner on Stack Overflow See other posts from Stack Overflow or by FrustratedWithFormsDesigner
Published on 2009-11-19T22:22:15Z Indexed on 2010/04/29 12:27 UTC
Read the original article Hit count: 474

Filed under:
|
|
|
|

Has anyone else noticed this phenomenon where dbms_output.put_line is unable to print more than 2000 characters at a time?

Script is:

set serveroutput on size 100000;

declare
    big_str varchar2(2009);
begin
    for i in 1..2009 loop
        big_str := big_str||'x';
    end loop;

    dbms_output.put_line(length(big_str));
    dbms_output.put_line(big_str);
end;

/

I copied and pasted the output into an editor (Notepad++) which told me there were only 2000 characters, not 2009 which is what I think should have been pasted. This also happens with a few of my test scripts - only 2000 characters get printed.

I have a workaround to print like this:

dbms_output.put_line(length(big_str));
dbms_output.put_line(substr(big_str,1,1999));
dbms_output.put_line(substr(big_str,2000));

This adds new lines to the output, makes it hard to read when the text you're working with is preformatted.

Has anyone else noticed this? Is it really a bug or some sort of obscure feature? Is there a better workaround? Is there any other information on this out there?

Oracle version is: 10.2.0.3.0, using PL/SQL Developer (from Allround Automation).

© Stack Overflow or respective owner

Related posts about Oracle

Related posts about plsql