我是编写存储过程的新手。我有以下包裹:
create or replace PACKAGE STATUS_QUEUE AS
procedure get_errd (in_cd in char, in_sys in varchar2, out_info_cur out user_types.ref_cursor);
END STATUS_QUEUE;
和包体:
create or replace
PACKAGE BODY STATUS_QUEUE AS
procedure get_errd (in_cd in char, in_sys in varchar2, out_info_cur out user_types.ref_cursor)
is dttmFormat varchar2(21);
BEGIN
dttmFormat := common_functions.get_timestamp_format(in_stts_dttm);
open out_info_cur for
select email_frmt_name, bdy_text, sbjt_text, sys_id, crte_mdl_name, rtrn_email_addr_name,
to_char(stts_dttm, common_functions.get_dttm_pattern()) as stts_dttm, stts_cd
from pih.email_last_status
where stts_cd = in_cd AND sys_id = in_sys
order by STTS_DTTM desc;
END get_errd;
END STATUS_QUEUE;
运行时收到以下错误:
Connecting to the database hwvaldd3051.
ORA-06550: line 5, column 27:
PLS-00302: component 'REF_CURSOR' must be declared
ORA-06550: line 5, column 16:
PL/SQL: Item ignored
ORA-06550: line 15, column 21:
PLS-00320: the declaration of the type of this expression is incomplete or malformed
ORA-06550: line 11, column 3:
PL/SQL: Statement ignored
ORA-06550: line 20, column 20:
PLS-00320: the declaration of the type of this expression is incomplete or malformed
ORA-06550: line 20, column 3:
PL/SQL: Statement ignored
Process exited.
Disconnecting from the database hwvaldd3051.
PL / SQL块是:
DECLARE
IN_STTS_CD CHAR(200);
IN_STTS_SYS VARCHAR2(200);
IN_STTS_DTTM VARCHAR2(200);
OUT_INFO_CUR user_types.ref_cursor;
BEGIN
IN_STTS_CD := 'ERRD';
IN_STTS_SYS := 'jwg';
IN_STTS_DTTM := NULL;
JWG.STATUS_QUEUE.GET_ERRD(
IN_STTS_CD => IN_STTS_CD,
IN_STTS_SYS => IN_STTS_SYS,
IN_STTS_DTTM => IN_STTS_DTTM,
OUT_INFO_CUR => OUT_INFO_CUR
);
/* Legacy output: DBMS_OUTPUT.PUT_LINE('OUT_INFO_CUR = ' || OUT_INFO_CUR); */
:OUT_INFO_CUR := OUT_INFO_CUR; --<-- Cursor
END;
我不确定为什么我会在Ref_cursor
上收到错误。
答案 0 :(得分:1)
根据以下示例尝试类型SYS_REFCURSOR
:
declare
recieving_cur sys_refcursor;
procedure rc_test (out_cur out sys_refcursor)
is
begin
open out_cur for
select * from user_tables;
end rc_test;
begin
rc_test(recieving_cur);
end;