Name

SET SERVEROUTPUT

Synopsis

The SERVEROUTPUT setting controls whether SQL*Plus prints the output generated by the DBMS_OUTPUT package from PL/SQL procedures.

Syntax

SET SERVEROUT[PUT] {OFF | ON}
                    [SIZE buffer_size]
                    [FOR[MAT] {WRA[PPED] | WOR[D_WRAPPED] | TRU[NCATED]}]

Parameters

SET SERVEROUT[PUT]

Is the command, which may be abbreviated SET SERVEROUT.

OFF

Keeps PL/SQL output from being displayed. This is the default setting.

ON

Causes SQL*Plus to check for and display output generated by the DBMS_OUTPUT package after each PL/SQL block, procedure, or function you execute.

SIZE buffer_size

Sets the size of the buffer, in bytes, on the server that holds the output. This value can range from 2,000 to 1,000,000, and controls the maximum amount of output that any one PL/SQL routine can produce. The default buffer size is 2,000 bytes.

WRA[PPED]

Causes the output to be wrapped within the current line size. Line breaks will occur in the middle of words, if necessary.

WOR[D_WRAPPED]

Causes the output to be word-wrapped within the current line size. Line breaks will occur only at word boundaries.

TRU[NCATED]

Causes any output longer than the line size to be truncated.

Examples

By default, SQL*Plus doesn’t display output from PL/SQL. The following example shows this:

SQL> BEGIN
  2    DBMS_OUTPUT.PUT_LINE('Hello World');
  3  END;
  4  /
PL/SQL procedure successfully completed.

The same block is executed again after issuing a SET SERVEROUTPUT ON command:

SQL> SET SERVEROUTPUT ON
SQL> BEGIN
  2    DBMS_OUTPUT.PUT_LINE('Hello ...

Get Oracle SQL*Plus: The Definitive Guide, 2nd Edition now with O’Reilly online learning.

O’Reilly members experience live online training, plus books, videos, and digital content from 200+ publishers.