create or replace procedure testprodurce is
cursor c_row is
select * from fpkj;
ref_c_row sys_refcursor;
-- ref_c_row
kplsh varchar2(200);
kplx number;
begin
for tmp in c_row loop
dbms_output.put_line(tmp.kplsh);
end loop;
/*
execute immediate 'select kplsh,kplx from fpkj where kplx=:1'
into ref_c_row
using 2;
不能into到cursor,只能类似count(*)into到number类型中
*/
open ref_c_row for 'select kplsh,kplx from fpkj where kplx=:1'
using 2;
loop
fetch ref_c_row
into kplsh, kplx;
exit when ref_c_row%notfound;
dbms_output.put_line(kplsh || '---->' || kplx);
end loop;
close ref_c_row;
declare
ct_fpkj number;
begin
execute immediate 'select count(*) from fpkj where kplx=:1'
into ct_fpkj
using 2;
dbms_output.put_line(ct_fpkj);
end;
end testprodurce;