SQL record-plsql-dbms output

Source: Internet
Author: User

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

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.