oracle 實現 if exists 方法的記錄

declare
    v_cnt number;
begin
      select count(*)  into v_cnt from dual  
          where exists (select * from tstp_schemedetail where auto_scheme_id = '123');
      if v_cnt = 0 then
           insert  into tstp_schemedetail( auto_scheme_id,stock_code, market_no)                                                                                                                                                                                                                                                                                          
                   values (  '28',   '3423',    '234') ;
      else 
           update tstp_schemedetail set stock_code='new_value' where auto_scheme_id = '123';
      end if;
 end;

參考文章:https://www.cnblogs.com/neru/archive/2012/06/23/2559551.html

 

發表評論
所有評論
還沒有人評論,想成為第一個評論的人麼? 請在上方評論欄輸入並且點擊發布.
相關文章