Dbms_output is a built-in package that is able to display output display debug information and send messages from PL/SQL blocks, subroutines, packages and triggers.
Let's take a look at a small snippet that will display all the user tables in the database.
//Try to list all the table names in the database: ' Tables in the database: ' ); For T in (SELECT table_name from user_tables) LOOP dbms_output.put_line (t.table_name); END LOOP; END; /
dbms_output subroutine
dbms_output contains the following sub-programs:
S.N |
Sub-Program and purpose |
1 |
dbms_output. DISABLE; Suppress information output |
2 |
dbms_output. ENABLE (buffer_size in INTEGER DEFAULT 20000); Enable message output. Buffer_size=null represents an infinite buffer size |
|
3 |
dbms_output. Get_line (Line out VARCHAR2, status out INTEGER); retrieves a single line of cached information |
4 |
dbms_output. Get_lines (LINES out Chararr, numlines in Out INTEGER); retrieves an array of rows from the buffer |
5 |
dbms_output. New_line; place end of line flag |
6 |
dbms_output. PUT (item in VARCHAR2); partial line placed in the buffer |
7 |
dbms_output. Put_Line (item in VARCHAR2); rows placed in the buffer |
Ii. examples
DECLARE lines Dbms_output.chararr; Num_lines number; BEGIN--Enable the buffer withdefaultSize20000dbms_output.enable; Dbms_output.put_line ('Hello reader!'); Dbms_output.put_line ('Hope You have enjoyed the tutorials!'); Dbms_output.put_line ('Have a great time exploring pl/sql!'); Num_lines:=3; Dbms_output.get_lines (lines, num_lines); For I in1.. Num_lines LOOP Dbms_output.put_line (lines (i)); END LOOP; END;///when the above code is executed at the SQL prompt, it produces the following results:Hello Reader!Hope You have enjoyed the tutorials!Have a great time exploring PL/sql!PL/sql procedure successfully completed.
(17) PL/SQL DBMS output