SQL 为什么 PLSQL Anonymous 块完成时没有输出?
声明:本页面是StackOverFlow热门问题的中英对照翻译,遵循CC BY-SA 4.0协议,如果您需要使用它,必须同样遵循CC BY-SA许可,注明原文地址和作者信息,同时你必须将它归于原作者(不是我):StackOverFlow
原文地址: http://stackoverflow.com/questions/14803195/
Warning: these are provided under cc-by-sa 4.0 license. You are free to use/share it, But you must attribute it to the original authors (not me):
StackOverFlow
Why no output when PLSQL Anonymous block completes?
提问by user1817081
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?
我刚刚进入 PL/SQL,我尝试运行以下代码,并且我正在完成匿名块,但我认为我应该获得测试输出。有谁知道我做错了什么?
DECLARE
message varchar2(20) := 'Testing output';
BEGIN
dbms_output.put_line(message);
END;
/
回答by Lews Therin
Viewing the DBMS_OUTPUT depends on the program.
查看 DBMS_OUTPUT 取决于程序。
SQL*Plus and Oracle SQL Developer
SQL*Plus 和 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;
。这就是 SQL*Plus 或最新版本的 Oracle SQL Developer 所需的全部内容。
SET SERVEROUTPUT ON;
begin
dbms_output.put_line('Testing output');
end;
/
PL/SQL Developer
PL/SQL 开发人员
Output is automatically detected and displayed in the "Output" tab.
输出会自动检测并显示在“输出”选项卡中。
回答by Alvin Bunk
Yes, in Oracle SQL Developer put the statement:
是的,在 Oracle SQL Developer 中放置语句:
SET SERVEROUTPUT ON;
just before your DECLARE
keyword and this should work.
就在您的DECLARE
关键字之前,这应该有效。
I couldn't find View -> DBMS Output
and I'm using version 1.5.5.
我找不到View -> DBMS Output
,我使用的是 1.5.5 版。
回答by MADHAIYAN M
Yes. There is way to see output in SQL Developer.
是的。有办法在 SQL Developer 中查看输出。
Click ->View->Dbms Output and then click + symbol on Dbms output window. now you can run the procedure and can see output.
单击 -> 查看 -> Dbms 输出,然后单击 Dbms 输出窗口上的 + 符号。现在您可以运行该过程并可以看到输出。
回答by Pronab Roy
`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
c 的值:30 f 的值:23.3333333333333333333333333333333333333
PL/SQL procedure successfully completed.
PL/SQL 过程成功完成。
回答by user2001117
Yes, this is correct. You need to use before this block:
是的,这是正确的。您需要在此块之前使用:
SET SERVEROUTPUT ON
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.
否则我们可以检查 SQL Developer select "View" -> "DBMS Output"
。
在选项卡PLSQL developer
下,OutPut
我们可以检查消息。
回答by Sunil Kumar Sahu
**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
回答by Bablu Gope
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
如果您在执行过程时通过键入“EXECUTE ;”获得“匿名块完成” 然后运行以下命令并再次执行该过程。命令是
SET SERVEROUTPUT ON;
设置服务器输出;