簡體   English   中英

Pl / SQL代碼未提供任何輸出

[英]The Pl/SQL Code doesn't give any output

我是PL / SQL編碼的初學者。 這是一個測試程序。

您能告訴我沒有輸出的原因嗎?

請指導我。

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;
/

您需要將Oracle設置為手動向控制台輸出行:

set serveroutput on;

這應該是代碼中的第一行。

  1. 正如其他人所說,如果您首先SET SERVEROUT ON ,則SQL * Plus將僅從DBMS_OUTPUT獲取輸出。
  2. 您的代碼僅編譯並在數據庫中存儲數據庫包。 您實際上並沒有運行它。 要運行它,您將執行以下操作:

     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. 

因此,SET SERVEROUTPUT ON僅適用於SQL * Plus。

暫無
暫無

聲明:本站的技術帖子網頁,遵循CC BY-SA 4.0協議,如果您需要轉載,請注明本站網址或者原文地址。任何問題請咨詢:yoyou2525@163.com.

 
粵ICP備18138465號  © 2020-2024 STACKOOM.COM