mysql 存储过程记录

declare
  cursor c1 is
    select rowid from wjf.wjf_t01 where state is null;
  type typ_row_id is table of urowid index by binary_integer;
  v_doi typ_row_id;
begin
  open c1;
  loop
    fetch c1 bulk collect
      into v_doi limit 10000;
    forall v_rec in 1 .. v_doi.count
      update wjf.wjf_t01
         set state = 1
       where rowid = v_doi(v_rec);
    commit;
    exit when c1%notfound;
  end loop;
  close c1;
  commit;
end;


URSOR cur IS
     SELECT * FROM t_ref;
   TYPE rec IS TABLE OF t_ref%ROWTYPE;
   recs rec;
 BEGIN
   OPEN cur;
   WHILE (TRUE) LOOP
     FETCH cur BULK COLLECT
       INTO recs LIMIT 100;
     FORALL i IN 1 .. recs.COUNT
       INSERT INTO t VALUES recs (i);
     COMMIT;
     EXIT WHEN cur%NOTFOUND;
   END LOOP;
   CLOSE cur;
 END;
原文地址:https://www.cnblogs.com/Struts-pring/p/12421627.html