3

output for below code

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;

/
5
  • 2
    did you forget to ´SET SERVEROUTPUT ON´? Commented Nov 28, 2021 at 11:54
  • If the issue is output, you can test it with 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? Commented Nov 28, 2021 at 17:02
  • 3
    From the screenshot it seems you are using SQL Developer, which has a slightly complicated way of displaying dbms_output. First you have to show the dbms_output pane using View > DBMS_OUTPUT. Then you have to enable it by pressing the green "+" symbol in the dbms_output pane. Commented Nov 28, 2021 at 19:00
  • @WilliamRobertson. I am just a new developer new to PL/SQL platform. While learning I got this issue. Commented Nov 29, 2021 at 4:19
  • What is your question? Commented Dec 1, 2021 at 18:38

1 Answer 1

9

In SQL Developer you have to

  1. Show the DBMS_OUTPUT pane using View > DBMS_OUTPUT.

enter image description here

  1. Enable it by pressing the green "+" symbol in the output pane.

enter image description here

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.
Sign up to request clarification or add additional context in comments.

4 Comments

You don't have to, you can also just set serveroutput on
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.
Yes, that's it.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.