【问题标题】:Cursor Declaration Error光标声明错误
【发布时间】:2014-11-10 19:04:25
【问题描述】:

我是编写存储过程的新手。我有以下包裹:

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 上收到错误消息。

【问题讨论】:

    标签: stored-procedures plsql cursor


    【解决方案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;
    

    【讨论】:

      猜你喜欢
      • 2015-02-20
      • 1970-01-01
      • 2013-03-12
      • 1970-01-01
      • 1970-01-01
      • 2011-08-23
      • 2013-01-22
      • 2011-10-25
      • 2011-02-15
      相关资源
      最近更新 更多