17,086
社区成员
发帖
与我相关
我的任务
分享
--如果简单点这样写,与上面的功能类似,少了个临时变量而已
begin
update A set role_id = '111' where user_id='abc';
if sql%rowcount=0 then
insert into Acc1 values('111','abc');
end if;
commit;
end;
/
--如果更新,新增是同一个表,用merge into就可以了,如果不是用sql语句吧,例:
declare
v_count int:=0;
begin
select count(*) into v_count from A where user_id='abc';
if v_count<>0 then
update A set role_id = '111' where user_id='abc';
else
insert into Acc1 values('111','abc');
end if;
commit;
end;
/