create or replace procedure test_procedure is
--a表游标定义
cursor a_cursor is
select id from a;
--b表游标定义
cursor b_cursor(aid number) is
select id from b where b.id = aid;
begin
for a_cur in a_cursor loop
for b_cur in b_cursor(a_cur.id) loop
--这里是你要执行的操作,比如insert到c
insert into c values (b_cur.id);
commit;
end loop;
end loop;
语法是这样的,具体字段自己改一下,看你要做什么样的操作了但如果是这种插入到一张表逻辑过于简单,可以直接用等值连接。
结果集a用游标得到,然后loop循环a,循环每一行,然后得到结果集b,再去做你所说的“其他操作”,然后写到中间表。
create or replace procedure test_procedure is
--a表游标定义
cursor a_cursor is
select id from a;
--b表游标定义
cursor b_cursor(aid number) is
select id from b where b.id = aid;
begin
for a_cur in a_cursor loop
for b_cur in b_cursor(a_cur.id) loop
--这里是你要执行的操作,比如insert到c
insert into c values (b_cur.id);
commit;
end loop;
end loop;