17,086
社区成员
发帖
与我相关
我的任务
分享
declare
A outcursor;
V_R A%ROWTYPE;
BEGIN
AAAAA(A,prm_orgName);--第一个参数为游标,第二个参数根据你的需要写
loop
fetch A INTO V_R;
EXIT WHEN A %NOTFOUND;
begin
INSERT INTO ......
exception when others then
null;
end;
END LOOP;
CLOSE A;
END;
insert into T(C1,C2,C3)SELECT C1,C2,C3 FROM temp
create or replace procedure sql_test (pi1 number,po out sys_refcursor) is
begin
if pi1=1 then
open po for 'select 1 id,''Tom'' nm from dual union all select 2 id,''Jack'' from dual';
else
open po for 'select 3 id,''Lucy'' nm from dual union all select 4 id,''Lily'' from dual';
end if;
end ;
/
--调用
set serveroutput on;
declare
cur1 SYS_REFCURSOR;
id number;
nm varchar2(100);
begin
sql_test(1,cur1);
loop
fetch cur1 into id,nm;
exit when cur1%notfound;
dbms_output.put_line(id||':'||nm);
end loop;
close cur1;
end;
/