for 迴圈境實現遊標LOOP提取

hurp_oracle發表於2015-08-07
create or replace procedure p_repaire_data_route_nbr is
  cnt number(7) :=0;
begin
  for cl in (select a.*,rowid from KXD_TMP_ERRNBR a where servnumber like '1064%' and flag is null) loop
    for cl2 in (select * from subs_telnum t where value = cl.servnumber and t.expiretime> sysdate) loop
      update v_repaire_data_route_nbr set data_nodeid=cl.CUST where servnumber = cl.servnumber and starttime=cl2.availtime;
    end loop;
    update KXD_TMP_ERRNBR a set a.flag=1 
where rowid=cl.rowid;
    cnt :=cnt+1;
    if(mod(cnt,100) =0) then
      commit;
      dbms_lock.sleep(120);
    end if;
  end loop;
  commit;
end p_repaire_data_route_nbr;

來自 “ ITPUB部落格 ” ,連結:http://blog.itpub.net/29446986/viewspace-1764994/,如需轉載,請註明出處,否則將追究法律責任。

相關文章