Oracle 存储过程中的For循环使用实例

create or replace procedure deleteLgZS is
 cursor getList is select ryid from qbzhpt.t_ys_ry a where a.ywgl='0000000100000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000' ;
 type getRyIDLIST is table of getList%rowtype;
 r_rk getRyIDLIST;
 begin
   open getList;
       loop  
           fetch getList bulk collect
              into r_rk limit 1000;
            exit when r_rk.count=0;
              for i in r_rk.first .. r_rk.last loop
                  delete  from qbzhpt.t_ys_ry a
                    where a.ryid=r_rk(i).ryid and a.ywgl='0000000100000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000' ;
              end loop;
              commit;
       end loop ;
     
   close getList;
  
 end ;

你可能感兴趣的:(Oracle)