Wednesday, August 28, 2013

Difference between dbms_output.put, dbms_output.put_line, dbms_output.new_line

Objective: Behavior of dbms_output.put, dbms_output.put_line, dbms_output.new_line

Applies to Oracle Database.

dbms_output.new_line need to be used followed by dbms_output.put to display the buffer value to the output screen or to be printed (OR) would need to use dbms_output.put_line instead of dbms_output.put.

SQL> set serveroutput on;

SQL> begin
  2  dbms_output.put('hello');
  3  end;
  4  /

PL/SQL procedure successfully completed.

SQL> begin
  2  dbms_output.put_line('hello');
  3  end;
  4  /

SQLPLUS Output:

hello

PL/SQL procedure successfully completed.

SQL> begin
  2   dbms_output.put('hello');
  3  dbms_output.new_line;
  4  end;
  5  /

SQLPLUS Output:

hello

PL/SQL procedure successfully completed.

dbms_output.put by itself will not display or print to the output screen.  It needs to pair up with dbms_output.new_line to successfully display the output.

No comments:

Post a Comment