create or replace procedure aaa is num number; begin select count(*) into num from a where col1 is null; if num=0 then insert into .... else insert into... end if; commit; end aaa;
没有看清题目 create or replace procedure aaa(str in varchar2) is num number; begin select count(*) into num from a where col1=str; if num=0 then ... else .... end if; commit; end aaa; if...else中插入你要insert的操作
首先,A不是个VIew,所以不能写成Insteadof 触发器,
其次,若用Before Insert触发器,B表录入了数据,但是A中仍然有2条记录。要求A中只有1条记录。
如果符合你的要求,最后就来个 :old = :old
is
num number;
begin
select count(*) into num from a where col1 is null;
if num=0 then
insert into ....
else
insert into...
end if;
commit;
end aaa;
create or replace procedure aaa(str in varchar2)
is
num number;
begin
select count(*) into num from a where col1=str;
if num=0 then
...
else
....
end if;
commit;
end aaa;
if...else中插入你要insert的操作