我正在使用Oracle sql Developer,但是在查看返回引用游标的包的结果时遇到问题.以下是包装定义:
CREATE OR REPLACE package instance.lswkt_chgoff_recov as type rec_type is record ( source_cd lswk_tpr.gltrans.tpr_source_cd%TYPE,as_of_dt lswk_tpr.gltrans.tpr_as_of_dt%TYPE,chrg_off_recov varchar2(5),process_dt lswk_tpr.gltrans.dtgltran%TYPE,effect_dt lswk_tpr.gltrans.dtgltran%TYPE,account_nbr lswk_tpr.contract.lcontid%TYPE,naics_cd lswk_tpr.udfdata.sdata%TYPE,prod_type varchar2(20),off_nbr lswk_tpr.schedule.sctrcdty%TYPE,borrower_nm lswk_tpr.customer.scustnm%TYPE,tran_type_cd lswk_tpr.gltrans.sglcd%TYPE,tran_type_desc lswk_tpr.gltrans.sglcd%TYPE,tran_amt lswk_tpr.gltrans.ctranamt%TYPE,note_dt lswk_tpr.schedule.dtbk%TYPE,accru_cd number,non_accr_cd lswk_tpr.schedule.dtlstincsus%TYPE,comm_sb_ind varchar2(4) ); type cur_type is ref cursor return rec_type; procedure sp ( p_as_of_dt in date,ref_cur in out cur_type ); end; /
我想这个问题是可能的,如果是的话,我需要做什么.我正在使用Oracle sql Developer 1.5.5.谢谢.
涉
DECLARE P_AS_OF_DT DATE; REF_CUR instance.LSWKT_CHGOFF_RECOV.CUR_TYPE; REF_CUR_row REF_CUR%ROWTYPE; BEGIN P_AS_OF_DT := '31-AUG-2009'; instance.LSWKT_CHGOFF_RECOV.SP ( P_AS_OF_DT,REF_CUR ); DBMS_OUTPUT.Put_Line('REF_CUR ='); IF REF_CUR%ISOPEN THEN DBMS_OUTPUT.Put_Line(' SOURCE_CD AS_OF_DT CHRG_OFF_RECOV PROCESS_DT EFFECT_DT ACCOUNT_NBR NAICS_CD PROD_TYPE OFF_NBR BORROWER_NM TRAN_TYPE_CD TRAN_TYPE_DESC TRAN_AMT NOTE_DT ACCRU_CD NON_ACCR_CD COMM_SB_IND'); LOOP FETCH REF_CUR INTO REF_CUR_row; EXIT WHEN REF_CUR%NOTFOUND; DBMS_OUTPUT.Put_Line( ' ' || '[TPR_SOURCE_CD%type]' || ' ' || '[TPR_AS_OF_DT%type]' || ' ' || '''' || REF_CUR_row.CHRG_OFF_RECOV || '''' || ' ' || '[DTGLTRAN%type]' || ' ' || '[DTGLTRAN%type]' || ' ' || '[LCONTID%type]' || ' ' || '[SDATA%type]' || ' ' || '''' || REF_CUR_row.PROD_TYPE || '''' || ' ' || '[SCTRCDTY%type]' || ' ' || '[SCUSTNM%type]' || ' ' || '[SGLCD%type]' || ' ' || '[SGLCD%type]' || ' ' || '[CTRANAMT%type]' || ' ' || '[DTBK%type]' || ' ' || NVL(TO_CHAR(REF_CUR_row.ACCRU_CD),'NULL') || ' ' || '[DTLSTINCSUS%type]' || ' ' || '''' || REF_CUR_row.COMM_SB_IND || ''''); END LOOP; ELSE DBMS_OUTPUT.Put_line(' (Ref Cursor is closed)'); END IF; COMMIT; END;
我收到错误:
希望这会让它更加清晰.
您可以在sql Developer中轻松打印ref_cursor的输出结果以查看返回值.
原文链接:https://www.f2er.com/oracle/205132.html这是一个Refcursor函数的例子:
create or replace function get_employees() return sys_refcursor as ret_cursor sys_refcursor; begin open ret_cursor for select * from employees; return ret_cursor; end get_employees;
select get_employees() from dual;
干净整洁的方法:
variable v_ref_cursor refcursor; exec :v_ref_cursor := get_employees(); print :v_ref_cursor