簡單存儲過程

導入數據時,判斷格式錯誤,重複數據ui

 

CREATE DEFINER=`root`@`%` PROCEDURE `p_impt_order`(IN `p_uid` int,OUT `out_rst` int)
BEGIN
    
    set out_rst = 0;
  start TRANSACTION;
  -- 導入失敗
    update eph_ispc_order_temp set impt_flg = 1
    where crt_uid = p_uid
    and LENGTH(mchnt_cd) > 15;
commit;
start TRANSACTION;
  -- 導入重複
  update eph_ispc_order_temp a set impt_flg = 2
where crt_uid = p_uid
  and CONCAT(IFNULL(mchnt_cd,''),IFNULL(term_id,'')) IN
(select CONCAT(IFNULL(mchnt_cd,''),IFNULL(term_id,''))
   from eph_ispc_order_his b where a.crt_dept_cd = b.crt_dept_cd);
commit;
start TRANSACTION;
 update eph_ispc_order_temp set impt_flg = 3
    where crt_uid = p_uid
    and impt_flg is null;
commit;
 set out_rst = 1;

ENDit

相關文章
相關標籤/搜索