DECLARE
a int;
b int;
c int;
BEGIN
a:=&a;
b:=&b;
c:=a+b;
dbms_output.put_line('Sum of a and b is '||c);
end;
/
1 Answer
In SQL Developer you have to
- Show the DBMS_OUTPUT pane using View > DBMS_OUTPUT.
- Enable it by pressing the green "+" symbol in the output pane.
For more details including how to have dbms_output enabled by default for all sessions, see www.thatjeffsmith.com/archive/2012/05/enabling-dbms_output-by-default-in-sql-developer
Step by step instructions from Jeff Smith's post:
- Open a new worksheet.
- Code this line:
set serverout on - Save to 'startup.sql' in some convenient folder
- 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.
4 Comments
thatjeffsmith
You don't have to, you can also just set serveroutput on
William Robertson
Hi Jeff, do you have a link to a definitive how-to guide for enabling DBMS_OUTPUT in SQL Developer? Happy to edit the above.
William Robertson
Actually maybe it's thatjeffsmith.com/archive/2012/05/…
thatjeffsmith
Yes, that's it.


dbms_output.put_line('Hello');and skip all the arithmetic stuff. Are you actually using PL/SQL Developer or did you just tag it because the question is about development in PL/SQL?