web analytics

Oracle: buffer overflow (ORU-10027)

Sometimes it’s necessary to show the output of the PL/SQL script.
Usually the dbms_output package is used:

SET serveroutput ON
DECLARE
 i NUMBER ;
BEGIN
 i:=0 ;
 WHILE i< 100000 LOOP
  i:=i+1 ;
  dbms_output.put_line('This is just test line #' || TO_CHAR(i) ) ;
 END LOOP ;
END;
/

After several thousands lines the following error message is displayed:

ORA-20000: ORU-10027: buffer overflow, limit of 20000 bytes
ORA-06512: at “SYS.DBMS_OUTPUT”, line 32
ORA-06512: at “SYS.DBMS_OUTPUT”, line 97
ORA-06512: at “SYS.DBMS_OUTPUT”, line 112
ORA-06512: at line 8

The error message means, that the internal buffer of dbms_output is full. How to increase it?
The following methods could be used:

...
dbms_package.enable(100000) ;
...
...
SET serveroutput ON SIZE 100000
...

In Oracle 10gR2 the new addition “size unlimited” could be used:

...
SET serveroutput ON SIZE unlimited
...

If these methods do not work, the temporary table could be used:

CREATE SEQUENCE my_output_seq ;
CREATE global TEMPORARY TABLE my_output_table( my_row NUMBER, my_out VARCHAR2(120) ) ;
...
INSERT INTO my_output_table VALUES ( my_output_seq.NEXTVAL, 'This is some string' ) ;
...
SELECT my_out FROM my_output_table ORDER BY my_row ;
DROP TABLE my_output_table ;
DROP SEQUENCE my_output_seq ;

Leave a Reply

You can use these HTML tags

<a href="" title=""> <abbr title=""> <acronym title=""> <b> <blockquote cite=""> <cite> <code> <del datetime=""> <em> <i> <q cite=""> <s> <strike> <strong>

  

  

  

Categories

A sample text widget

Etiam pulvinar consectetur dolor sed malesuada. Ut convallis euismod dolor nec pretium. Nunc ut tristique massa.

Nam sodales mi vitae dolor ullamcorper et vulputate enim accumsan. Morbi orci magna, tincidunt vitae molestie nec, molestie at mi. Nulla nulla lorem, suscipit in posuere in, interdum non magna.