PL/SQL DBMS output
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. We have used this package in all of our tutorials.
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:
BEGINDbms_output.Put_Line(user | | ); for T in ( select table_name from User_tables) LOOP dbms_output. (t. Table_name end Loop;end;
Dbms_output Sub-Program
Dbms_output contains the following sub-programs:
S.N |
Sub-procedures and uses |
1 |
Dbms_output. DISABLE; Suppress information output |
2 |
Dbms_output. ENABLE (buffer_size in INTEGER DEFAULT 20000); Enables 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); Retrieving an array of rows from a buffer |
5 |
Dbms_output. New_line; Flag to place line end |
6 |
Dbms_output. PUT (item in VARCHAR2); A portion of the line placed in the buffer |
7 |
Dbms_output. Put_Line (item in VARCHAR2); The line placed in the buffer |
Example:
DECLARELines Dbms_output.Chararr;Num_lines number;BEGIN --Enable the buffer with default size 20000Dbms_output.Enable;Dbms_output.Put_Line(' Hello reader! ');Dbms_output.Put_Line(' Hope you enjoyed the tutorials! ');Dbms_output.Put_Line(' A great time exploring pl/sql! ');Num_lines:= 3; Dbms_output.get_lines (lines, num_lines< Span class= "pun"); for I in1.. Num_lines LOOP dbms_output.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.
SQL record-plsql-dbms output