DBMS_OUTPUT built-in package

The DBMS_OUTPUT is a built-in package that enables you to display output, display debugging information, and send messages from PL/SQL blocks, subprograms, packages, and triggers.
Example:
BEGIN
   dbms_output.put_line  (user || ' Tables :');
   FOR t IN (SELECT table_name FROM user_tables)
   LOOP
      dbms_output.put_line(t.table_name);
   END LOOP;
END;
/

DBMS_OUTPUT Subprograms

The DBMS_OUTPUT package has the following subprograms:
S.N Subprogram & Purpose
1 DBMS_OUTPUT.DISABLE; Disables message output
2 DBMS_OUTPUT.ENABLE(buffer_size IN INTEGER DEFAULT 20000); Enables message output. A NULL value of buffer_size represents unlimited buffer size.

3 DBMS_OUTPUT.GET_LINE (line OUT VARCHAR2, status OUT INTEGER); Retrieves a single line of buffered information.
4 DBMS_OUTPUT.GET_LINES (lines OUT CHARARR, numlines IN OUT INTEGER); Retrieves an array of lines from the buffer.
5 DBMS_OUTPUT.NEW_LINE; Puts an end-of-line marker
6 DBMS_OUTPUT.PUT(item IN VARCHAR2); Places a partial line in the buffer.
7 DBMS_OUTPUT.PUT_LINE(item IN VARCHAR2); Places a line in the buffer.

Example:

DECLARE
   lines dbms_output.chararr;
   num_lines number;
BEGIN
   -- enable the buffer with default size 20000
   dbms_output.enable;
  
   dbms_output.put_line('Hello World!');
   dbms_output.put_line('Hope you Had Useful Time with Learn Oracle with Yasser!');
   dbms_output.put_line('Have a great time exploring pl/sql!');
 
   num_lines := 3;
 
   dbms_output.get_lines(lines, num_lines);
 
   FOR i IN 1..num_lines LOOP
      dbms_output.put_line(lines(i));
   END LOOP;
END;
/
result: will be
Hello World!
Hope you Had Useful Time with Learn Oracle with Yasser!
Have a great time exploring pl/sql!

PL/SQL procedure successfully completed.

No comments:

Post a Comment