Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations strongm on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

question for a simple block...

Status
Not open for further replies.

Guest_imported

New member
Jan 1, 1970
0
why can't i see anything on sqlplus with the following anonymous block?? am i doing anything wrong??


declare
begin
DBMS_OUTPUT.PUT_LINE( 'HELLO WORLD' );
END;
 
First set server output on
and then process.
Example:

set serveroutput on;
declare
begin
DBMS_OUTPUT.PUT_LINE( 'HELLO WORLD' );
END;
this should work now!!
sarc
 
oh, one thing to remember!
You may have to remove the semi-colon (;)
like this:

set serveroutput on
declare
begin
DBMS_OUTPUT.PUT_LINE( 'HELLO WORLD' );
END;
sarc
 
Go to URL:

Found the following on tech net at the URL above:

The DBMS_OUTPUT package enables you to send messages from stored procedures, packages, and triggers.

The PUT and PUT_LINE procedures in this package enable you to place information in a buffer that can be read by another trigger, procedure, or package. In a separate PL/SQL procedure or anonymous block, you can display the buffered information by calling the GET_LINE procedure.

If you do not call GET_LINE, or if you do not display the messages on your screen in SQL*Plus or Enterprise Manager, then the buffered messages are ignored. The DBMS_OUTPUT package is especially useful for displaying PL/SQL debugging information.

Note:
Messages sent using DBMS_OUTPUT are not actually sent until the sending subprogram or trigger completes. There is no mechanism to flush output during the execution of a procedure.

Using DBMS_OUTPUT
A trigger might want to print out some debugging information. To do this, the trigger would do:

DBMS_OUTPUT.PUT_LINE('I got here:'||:new.col||' is the new value');

If you have enabled the DBMS_OUTPUT package, then this PUT_LINE would be buffered, and you could, after executing the statement (presumably some INSERT, DELETE, or UPDATE that caused the trigger to fire), get the line of information back. For example:

BEGIN
DBMS_OUTPUT.GET_LINE:)buffer, :status);
END;

It could then display the buffer on the screen. You repeat calls to GET_LINE until status comes back as non-zero. For better performance, you should use calls to GET_LINES which can return an array of lines.

Enterprise Manager and SQL*Plus implement a SET SERVEROUTPUT ON command to know whether to make calls to GET_LINE(S) after issuing INSERT, UPDATE, DELETE or anonymous PL/SQL calls (these are the only ones that can cause triggers or stored procedures to be executed).
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top