(17) PL/SQL DBMS output

Source: Internet
Author: User

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

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.