The following error occurs when you use dbms_output.put_line to output the statement:
Begin user_priv (username => 'hr'); end;
ORA-20000: ORU-10027: buffer overflow, limit of 2000 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 "HR. USER_PRIV", line 20
ORA-06512: at line 2
Obviously, when we are outputting, the buffer size of the output result is controlled by DBMS_OUTPUT.ENABLE. The default buffer size is 20000, and the maximum limit of each row is 32 k, the following example shows that a stored procedure returns results only after all data is cached. So when we use a cursor for output, if there are a lot of results, it will exceed this value to report ORA-20000, ORU-10027: Buffer overflow, limit of <buf_limit> bytes this error
Solution:
Add DBMS_OUTPUT.ENABLE (buffer_size => null) after the Stored Procedure begin to indicate that there is no limit.
For the Stored Procedure user_priv, see the document: