0

私は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;
/
4

3 に答える 3

3

手動でコンソールに行を出力するようにOracleを設定する必要があります。

set serveroutput on;

これは、コードの最初の行になります。

于 2013-03-24T19:40:15.267 に答える
1
  1. 他の人が言っているように、SQL * Plusは、最初にSET SERVEROUT ON
  2. コードは、データベースパッケージをコンパイルしてデータベースに保存するだけです。あなたは実際にそれを実行していません。それを実行するには、次のようなものを実行します。

    BEGIN menu.show('something'); END;
    /
    
于 2013-03-26T07:20:57.850 に答える
0

ドキュメントをお読みください

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.

したがって、SETSERVEROUTPUTONはSQL*Plus専用です。

于 2013-03-25T09:58:30.737 に答える