merge into a using b on (a.a=b.b) when matched then update xxxxx when not matched then insert (xxx) values(xxx);
很好的merge,另外就是存储了,感觉没必要写存储
declare vi number :=0; v_rowid varchar2(18); begin begin select t.rowid into v_rowid from tablexxx t where t.idxx = 'xxxid'; exception when others then v_rowid := ''; end; if v_rowid is null then insert into xxx......; else update tablexxx t set ...... where t.rowid = v_rowid; end if; exception when others then null; end;
merge into a
using b
on (a.a=b.b)
when matched then update xxxxx
when not matched then insert (xxx) values(xxx);
vi number :=0;
v_rowid varchar2(18);
begin
begin
select t.rowid
into v_rowid
from tablexxx t
where t.idxx = 'xxxid';
exception
when others then
v_rowid := '';
end;
if v_rowid is null then
insert into xxx......;
else
update tablexxx t
set ......
where t.rowid = v_rowid;
end if;
exception
when others then
null;
end;