时间:2021-07-01 10:21:17 帮助过:23人阅读
merge into sn_balance b1 using(select ‘admin‘ as userid,1 as type1 from dual) b2 on(b1.userid=b2.userid and b1.type=b2.type1)
when matched then
update set b1.Remainder = (select Remainder from sn_balance t where t.userid = b1.userid and t.type = b1.type )+100
when not matched then
insert (userid, remainder, type,createtime) values(‘admin‘,100,1, sysdate)
注:1.程序中将对应的admin , 1 100 替换为变量即可;
2.如果 using部分没有查询到值,下面的update和insert 是不会执行的,所以 using中的一般使用虚拟表dual
oracle merge into 新增或者修改
标签:HERE rac rem bsp when type using nbsp balance