PL/SQL - SPLessons

PL/SQL Set Serveroutput ON

Chapter 9

SPLessons 5 Steps, 3 Clicks
5 Steps - 3 Clicks

PL/SQL Set Serveroutput ON

PL/SQL Set serveroutput ON

shape Description

In PL/SQL, one needs to compose the “PLSQL Set serveroutput ON” command. The server output checks whether PL/SQL will create the output or not. It prints the output created by the DBMS_OUTPUT package from PL/SQL methods. PL/SQL program executes in oracle engine so it is required to get server output result and display on the screen, else, the results will not be displayed.

shape Syntax

The syntax for PLSQL Set serveroutput ON command is as follows.

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

SET SERVER OUTPUT[PUT]

Is a command that can be attributed as SET SERVEROUT.

OFF

The OFF is a default built-in command. If the server output is OFF, it will not display the output.

ON

The PL/SQL will check and show the yield produced by the DBMS_OUTPUT bundle after each pl/sql function, procedure or block gets executed.

SIZE buffer_size

Arrange the buffer size on the server in bytes that range from 2,000 to 1,000,00. And, the output will be controlled and then produced for execution. By default, the size of the buffer is 2,000 bytes.

WRAP[PED]

The yield will be wrapped inside the present line size. And, this line size will happen amidst the words.

WOR[D_WRAPPED]

The yield will be wrapped inside the present line size. At the limits of word, the line break will happen.

TRU[NCATED]

The yield longer than the line size will be truncated.

shape Examples

The below example illustrates the SERVER OUTPUT ON program.

SQL> SET ECHO ON
SQL> SET SERVEROUTPUT ON
SQL> DECLARE
  2  age NATURAL;
  3  BEGIN
  4  age:=10;
  5  DBMS_OUTPUT.PUT_LINE('age: ');
  6  DBMS_OUTPUT.PUT_LINE(age);
  7  END;
  8  /
age:
10

PL/SQL procedure successfully completed.

The above example describes the SERVER OUTPUT ON program and displays the output as age = 10.

Summary

shape Key Points

  • PLSQL Set serveroutput ON – Is a command used in PL/SQL execution.