toad - PLSQL Viewing output of sys_refcursor -
i'm using toad oracle 11 , pretty new sql. have written proc , trying test , view output. have written following block:
declare cur_test sys_refcursor; type t_row record(psh_code varchar2(20) , pattr_end_date varchar2(20), pperf_gross varchar2(20)); r_test t_row; begin procperftr(xxx-xxxx', 'xxxxxxx', 'xxxxxxx', 'xxxxxx', :cur_test); loop fetch cur_test r_test; exit when cur_test%notfound; end loop; close cur_test; end; /
however, following error on loop line
ora-01001: invalid cursor
the error on line 10 line has "loop" on it
my proc looks this
create or replace procedure procperftr ( paramportfcode varchar2, paramenddate varchar2, paramshare varchar2, paramfreq varchar2, o_cursorperf out sys_refcursor ) i_cursorperf sys_refcursor; begin open i_cursorperf select ps.psh_code, pp.pattr_end_date, pp.pperf_gross portfolio_performances pp inner join portf_share ps on ps.portf_share_id = pp.portf_share_id inner join portfolio p on p.portf_id = ps.portf_id inner join t_frequency tf on tf.frequency_id = pp.frequency_id p.portf_code = paramportfcode , pp.pattr_calcul_date = pp.pattr_end_date , pp.pattr_end_date = paramenddate , tf.ext_code = paramfreq , ps.psh_code (case when paramshare = 'xxxx' '%xxx' when paramshare = 'xxxx' '%xxx' end); o_cursorperf:=i_cursorperf; end; /
in proc invocation, don't put colon in front of name of cursor. should like
procperftr('xxx-xxxx', 'xxxxxxx', 'xxxxxxx', 'xxxxxx', cur_test);
(note added single-quote @ start of first parameter, absence of took simple typo).
share , enjoy.
Comments
Post a Comment