当前位置: 代码迷 >> Oracle管理 >> PL/SQL 话语
  详细解决方案

PL/SQL 话语

热度:353   发布时间:2016-04-24 05:14:03.0
PL/SQL 语句
添加图书,如果数据库里有该图书信息,就把库存量增加, 如果没有就新增加条目
这个语句怎么写??

------解决方案--------------------
SQL code
merge into a using bon (a.a=b.b)when matched then update xxxxxwhen not matched then insert (xxx) values(xxx);
------解决方案--------------------
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;
  相关解决方案