问题:在oracle中更新数据时,有时需要线盘有无数据,有则直接更新,没有则直接新增
参考:https://blog.csdn.net/yangqinfeng1121/article/details/90672458
merge into table t1
using (select #{aa} as aa from dual) t2
on (t1.AA=t2.aa)
when matched then
update set t1.BB=#{bb},t1.CC=#{cc}
when not matched then
insert (AA,BB,CC)
values (#{aa},#{bb},#{cc})
结论:这样在更新数据时先判断有无数据,有数据则更新,没有数据则插入