Oracle插入数据时先查询是否存在,执行更新或者插入

-- Created on 2019/3/22 by ADMINISTRATOR 
declare 
  -- Local variables here
  i integer;
begin
  -- Test statements here
  select count(1) into i from BIGDATA_YXXT.M_ZW_SQGDQDB where id=1;   
    if i > 0 then   
      dbms_output.put_line('数据存在!');
      update BIGDATA_YXXT.M_ZW_SQGDQDB set ORDER_CODE='mmmmmm' where id=1 ; 
      else
      insert into  BIGDATA_YXXT.M_ZW_SQGDQDB(ORDER_CODE)values('shouwme'); 
      dbms_output.put_line('数据插入!');
      end if;
end;

 

posted @ 2019-03-22 09:50  黑魔术  阅读(4153)  评论(0编辑  收藏  举报