create or replace procedure pro_a is cnt number; cursor cur_a is select * from A; begin for rec in cur_a loopbegin --判断是否存在 select 字段 into cnt from B where B.字段=rec.字段; exception when no_data_found then insert into B values(rec.字段,rec.其他字段); commit; end;begin --判断字段M select 字段 into cnt from B where B.字段=rec.字段 and B.字段M=rec.字段M; exception when no_data_found then 做操作; end;end loop; end; /
声明部分改成: create or replace procedure pro_a is cnt A.字段%type; ......
create or replace procedure pro_a
is
cnt number;
cursor cur_a is select * from A;
begin
for rec in cur_a loopbegin --判断是否存在
select 字段 into cnt from B
where B.字段=rec.字段;
exception when no_data_found then
insert into B values(rec.字段,rec.其他字段);
commit;
end;begin --判断字段M
select 字段 into cnt from B
where B.字段=rec.字段
and B.字段M=rec.字段M;
exception when no_data_found then
做操作;
end;end loop;
end;
/
create or replace procedure pro_a
is
cnt A.字段%type;
......