[英]The Pl/SQL Code doesn't give any output
I'm a beginner in PL/SQL Coding. 我是PL / SQL编码的初学者。 This is a test program.
这是一个测试程序。
Can you please tell the reason for no output. 您能告诉我没有输出的原因吗?
Please guide me. 请指导我。
create or replace package menu as
procedure show(name varchar2);
end menu;
/
create or replace package body menu as
procedure show(name varchar2) AS
new_number number;
begin
select count(*) into new_number from stock;
dbms_output.put_line('This is output.');
end;
end menu;
/
You need to set Oracle to output lines to the console manually: 您需要将Oracle设置为手动向控制台输出行:
set serveroutput on;
This should be the first line in your code. 这应该是代码中的第一行。
SET SERVEROUT ON
. SET SERVEROUT ON
,则SQL * Plus将仅从DBMS_OUTPUT获取输出。 Your code merely compiles and stores a database package on the database; 您的代码仅编译并在数据库中存储数据库包。 you haven't actually run it.
您实际上并没有运行它。 To run it you'd execute something like this:
要运行它,您将执行以下操作:
BEGIN menu.show('something'); END; /
Operational Notes If you do not call GET_LINE, or if you do not display the messages on your screen in SQL*Plus, the buffered messages are ignored. SQL*Plus calls GET_LINES after issuing a SQL statement or anonymous PL/SQL calls. Typing SET SERVEROUTPUT ON in SQL*Plus has the effect of invoking DBMS_OUTPUT.ENABLE (buffer_size => NULL); with no limit on the output. You should generally avoid having application code invoke either the DISABLE Procedure or ENABLE Procedure because this could subvert the attempt of an external tool like SQL*Plus to control whether or not to display output. Note: Messages sent using DBMS_OUTPUT are not actually sent until the sending subprogram or trigger completes. There is no mechanism to flush output during the execution of a procedure. Exceptions DBMS_OUTPUT subprograms raise the application error ORA-20000, and the output procedures can return the following errors: Table 68-1 DBMS_OUTPUT Errors Error Description ORU-10027: Buffer overflow ORU-10028: Line length overflow Rules and Limits The maximum line size is 32767 bytes. The default buffer size is 20000 bytes. The minimum size is 2000 bytes and the maximum is unlimited.
So SET SERVEROUTPUT ON is only for SQL*Plus. 因此,SET SERVEROUTPUT ON仅适用于SQL * Plus。
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.