gib65
gib65

Reputation: 2021

How can I see output of dbms_output.put_line() in SQL window in PL/SQL Developer?

I'm not able to see the messages added to dbms_output.put_line() in PL/SQL Developer. Every google hit I see says to use set serveroutput on but this isn't working.

I try to run this script in a SQL Window:

set serveroutput on;

BEGIN
    dbms_output.put_line('hello')
END

But I get an error on the set serveroutput on line:

enter image description here

And I get no output in the Output tab (regardless of whether I have the set serveroutput on):

enter image description here

How can I see the output sent to dbms_output.put_line('hello') in a script run in an SQL Window?

Thank you.

Upvotes: 1

Views: 2091

Answers (1)

William Robertson
William Robertson

Reputation: 16001

That is because in PL/SQL Developer, a SQL Window can only contain either SQL or PL/SQL blocks. There is a checkbox for enabling or disabling dbms_output. SQL windows aren't really for scripts, unless the 'script' is a set of SQL queries or PL/SQL blocks and nothing else.

enter image description here

PL/SQL Developer SQL Window screenshot - output

(If there is more than one statement in the window, it may be helpful to add / as a terminator after the PL/SQL block, otherwise PL/SQL Developer won't know where one statement ends and the next begins unless you explicitly highlight it with the mouse.)

Alternatively, you could use set serverout on in a Command window (which is a SQL*Plus emulator), or better, use a Test window, which is specifically designed for executing PL/SQL blocks.

Upvotes: 1

Related Questions