【发布时间】:2021-12-27 10:16:39
【问题描述】:
我写了Stored Procedure (SP),其中在 SP 内部,2 个 SP 分开用于从表中插入 2 个。两个表在每个临时表和主表中都包含超过 25 列。以下是查询-
create or replace procedure sp_main as
procedure tbl1_ld as
cursor c1 is select * from tmp1;
type t_rec1 is table of c1%rowtype;
v_rec1 t_rec1;
begin
open c1;
loop
fetch c1 bulk collect into v_rec1 limit 1000;
exit when v_rec1.count=0;
insert into tbl1 values v_rec1;
end loop;
end tbl1_ld;
procedure tbl2_ld as
cursor c2 is select * from tmp2;
type t_rec2 is table of c2%rowtype;
v_rec2 t_rec2;
begin
open c2;
loop
fetch c2 bulk collect into v_rec2 limit 1000;
exit when v_rec2.count=0;
insert into tbl2 values v_rec2;
end loop;
end tbl2_ld;
begin
null;
end sp_main;
/
我使用EXECUTE IMMEDIATE 'insert into tbl1 select * from tmp1'; 在两个SP 中插入tbl1_ld & tbl2_ld 而不是使用cursor,SP 已编译但没有插入记录。
【问题讨论】:
标签: sql oracle stored-procedures plsql