Why no output when PLSQL Anonymous block completes

2019-01-11 13:24发布

This question already has an answer here:

I'm just getting into PL/SQL, and I tried to run the following code, and I am getting anonymous block completed, but I think I should be getting Testing output. Does any know what I am doing wrong?

DECLARE
   message varchar2(20) := 'Testing output';
BEGIN
   dbms_output.put_line(message);
END;
/

标签: sql oracle plsql
7条回答
家丑人穷心不美
2楼-- · 2019-01-11 13:59

`The following statement will give the possible solution try this out

SET SERVEROUTPUT ON;

Then Run this code will get the following output

declare
a integer :=10;
b integer :=20;
c integer;
f real;
begin
c := a+b;
dbms_output.put_line('value of c: ' || c);
f := 70.0/3.0;
dbms_output.put_line('value of f: ' || f);

end; /

The code will give the following output

value of c: 30 value of f: 23.3333333333333333333333333333333333333

PL/SQL procedure successfully completed.

查看更多
劫难
3楼-- · 2019-01-11 14:02

Yes, in Oracle SQL Developer put the statement:

SET SERVEROUTPUT ON;

just before your DECLARE keyword and this should work.

I couldn't find View -> DBMS Output and I'm using version 1.5.5.

查看更多
ゆ 、 Hurt°
4楼-- · 2019-01-11 14:08

Viewing the DBMS_OUTPUT depends on the program.

SQL*Plus and Oracle SQL Developer

Run SET SERVEROUTPUT ON; first. This is all that's necessary in SQL*Plus or recent versions of Oracle SQL Developer.

SET SERVEROUTPUT ON;
begin
    dbms_output.put_line('Testing output');
end;
/

PL/SQL Developer

Output is automatically detected and displayed in the "Output" tab.

查看更多
做自己的国王
5楼-- · 2019-01-11 14:18

Yes, this is correct. You need to use before this block:

SET SERVEROUTPUT ON

Then, message get displayed on window.

Else we can check in SQL Developer select "View" -> "DBMS Output".
and in PLSQL developer under the OutPut tab we can check message.

查看更多
疯言疯语
6楼-- · 2019-01-11 14:19
**SET SERVEROUTPUT ON;**
DECLARE
   a INTEGER :=10;
   b INTEGER :=20;
   c float ;
   d real ;

BEGIN
   c :=a+b;
   dbms_output.put_line('the value of C is :'|| c);
   d := 70.0/3.3;
   dbms_output.put_line('the value of d is:'|| d);
END;

This will give you the output

the value of C is: 30
the value of d is: 21.21212121212121212121212121212121212121
查看更多
聊天终结者
7楼-- · 2019-01-11 14:19

If you are getting "anonymous block completed" while executing the procedure by typing "EXECUTE ;" then run the below command & again execute the procedure. command is

SET SERVEROUTPUT ON;

查看更多
登录 后发表回答