DBMS_OUTPUT is one of the most well-known and least understood SYS packages. If you have questions about how it works in general, you might want to read my previous post on the subject.
What I want to show you today is a ‘trick’ that will help you bypass the step of enabling polling for DBMS_OUTPUT for all of your connections.
I’m all about saving clicks, so let’s save you 3 clicks right now.
Instead of clicking the ‘Enbable’ then selecting the connection then hitting ‘OK,’ we’re going to enable capture of the output be DEFAULT in SQL Developer.
We support SET SERVEROUTPUT
So try this. In your script use
SET SERVEROUTPUT ON Begin Dbms_Output.Put_Line(Systimestamp); End; /
Now run the script using F5.
Let’s check the DBMS_OUTPUT panel.
Instead of checking the DBMS_OUTPUT panel, check the ‘Script Output’ page.
But how do I get this to work by default?
Open a new worksheet.
Code this line
SET SERVEROUTPUT ON
Save to ‘startup.sql’
Open Tools – Preferences
Go to the Database page
On the ‘Filename for connection startup script’ – point to the ‘startup.sql’ file you just created.
Restart SQL Developer.
Open a connection and run your code.
You’ll see your DBMS_OUTPUT code with no more work!




Twitter
RSS
GooglePlus
Facebook
Jun 08, 2012 @ 14:04:34
This only seems to work the first time you run a script which makes sense since it is only run once at startup
Jun 08, 2012 @ 15:30:36
Hmmm, the session is shared, so that setting should persist throughout the connection. Let me go take a look and get back to you.
Dec 15, 2012 @ 09:50:03
Heeey thanks you!!!!
Saludos!
Dec 15, 2012 @ 11:16:06
De nada!
Jan 05, 2013 @ 06:15:10
Hi,
When try to use sys.Dbms_Output.Put_Line(Systimestamp);
I got an error message
Error starting at line 1 in command:
sys.Dbms_Output.Put_Line(Systimestamp)
Error report:
Unknown Command