Oracle FAQ | Your Portal to the Oracle Knowledge Grid |
Home -> Community -> Usenet -> c.d.o.misc -> Re: DBMS_OUTPUT.PUT_LINE doesn't work
On Sat, 24 Oct 1998 19:38:14 +0200, vagelis Hristidis <exrist_at_cc.ece.ntua.gr> wrote:
>I try to have some text printed in sqlplus.
>I type:
>
>exec DBMS_OUTPUT.enable;
>exec DBMS_OUTPUT.PUT_LINE('hallo');
> I get the answer "PL/SQL procedure successfully completed."
> for both commnads but nothing is printed.
>What's wrong?
The procedure DBMS_OUTPUT.ENABLE only enables the calls to DBMS_OUTPUT procedures. If the ENABLE procedure is not in force then the calls to other DBMS_OUTPUT procedures are simply ignored.
When ENABLE is in force, it simply means the output of calls to PUT and PUT_LINE are buffered. The contents of a buffer will *not* be printed to the output symply by ENABLEing the package! If you want to display the contents of a DBMS_OUTPUT buffer you have to call DBMS_OUTPUT.GET_LINE or GET_LINES procedure!
Hovewer, ServerManager (svrmgr, svrmgrl,...) and Sql*Plus can make this GET_LINE calls for you automaticaly after any insert, update, delete and anonymous plsql blocks if you enable this with the command "SET SERVEROUTPUT ON". Here are examples of both methods (manual and automatic output) using sqlplus:
SQL> variable x varchar2(100) SQL> variable y number SQL> REM serveroutput is off, we'll display output manualy! SQL> EXEC dbms_output.ENABLE;
PL/SQL procedure successfully completed.
SQL> EXEC dbms_output.PUT_LINE('First line');
PL/SQL procedure successfully completed.
SQL> EXEC dbms_output.PUT_LINE('Second line');
PL/SQL procedure successfully completed.
SQL> EXEC dbms_output.GET_LINE(:x, :y);
PL/SQL procedure successfully completed.
SQL> PRINT x
X
SQL> EXEC dbms_output.GET_LINE(:x, :y);
PL/SQL procedure successfully completed.
SQL> PRINT x
X
SQL> REM Now we'll enable automatic calls to GET_LINE SQL> SET SERVEROUTPUT ON SQL> EXEC dbms_output.put_line('First line');First line
PL/SQL procedure successfully completed.
SQL> EXEC dbms_output.put_line('Second line'); Second line
PL/SQL procedure successfully completed.
>Thanks in advance
>--
>Vagelis S. Hristidis
>Electrical and Computer Engineering
>National Technical University of Athens
>e-mail:exrist_at_cc.ece.ntua.gr
>URL:http://www.cc.ece.ntua.gr/~exrist
HTH,
Jurij Modic <jmodic_at_src.si>
Certified Oracle7 DBA (OCP)