oracle存储过程如何实现如果select * from a where id = 1,没有值时执行
select * from a where name = 'aa',如果还没有值,插入一条记录
--如果不行 可以联系我QQ434317590 探讨下
declare
v_count1 pls_integer;
v_count2 pls_integer;
begin
select count(*) into v_count1 from a where id = 1;
select count(*) into v_count2 from a where name = 'aa';
IF v_count1=0 AND v_count2=0 THEN
INSERT INTO 表
(字段1,字段2)
VALUES
(内容1,内容2);
END IF;
end;
insert when (not exists (select 1 from a where id = 1)) then
into a(...字段) values(...值)
insert when (not exists (select 1 from a where id = 1)) then
into a(...字段) values(...值)