Oracle中对于表数据的存在的Update不存在的INSERT

来源:互联网 发布:淘宝企业用户注册 编辑:程序博客网 时间:2024/06/06 08:33
  1. merge into membernum using (select count(id) count from membernum where phone =  1111 and ringid = 22 ) num2 on (num2.count <> 0 )     
  2.   
  3. when matched then update set balance = balance +222, totalnum = totalnum + 2222    
  4.   
  5. when not matched then insert (id, phone,ringid,totalnum,balance)    
  6.   
  7. values (SEQ_MEMBERNUM.nextval, 11111 ,2222 , 2222 , 2222)  

本sql语句对于Oracle9i以前的版本不可以。