plsql循环执行不同参数的过程

场景:由于工作需要,写了个过程,从门店传数据到总部,在执行过程时输入门店号,

开始时用Excel做好后复制粘贴到plsql里的命令窗口,缺点是每天手工传。

 

现在想通过循环执行这个过程另外单独写个过程,通过JOB每天自动运行。

create or replace procedure p_cs_hj is
begin
  declare
  v_mkt jhm_goodsmkt.mfcode%type;  --定义门店号变量
  cursor v_cur is select mfcode from jhm_goodsmkt@house where qybname='怀化区';  --定义游标并赋值门店号
begin
  open v_cur;   --打开游标
  loop     --进入循环
    fetch v_cur into v_mkt;   --变量获取游标门店号
    exit when v_cur%notfound or v_cur%notfound is null;   --游标里没有数据则退出
    begin
      p_cs_mkt(v_mkt);      --同步数据过程赋值变量
    exception when others then
      begin
       insert into cs_log values (v_mkt,trunc(sysdate));     --异常门店号保存
       commit;
      exception when others then
       rollback;
      end;
   --跳过通讯错误的门店
    end;
    end loop;
    close v_cur;
    commit;
end;
end p_cs_hj;

 

posted @ 2021-04-07 10:21  蜕变大哥  阅读(315)  评论(0)    收藏  举报