## Locking large tables via PL/SQL looping

   DECLARE
     CURSOR C1 IS 
       SELECT  EMP_NO 
       FROM    EMP
       WHERE   EMP_DEPT = 0020;
     CURSOR C2 IS
       SELECT  ROWID 
       FROM    EMP
       WHERE   EMP_NO   = :XEMP_NO
       AND     EMP_DEPT = 0020
       FOR     UPDATE;
   BEGIN
     KOUNTER = 0;
     OPEN C1;
     LOOP
       FETCH C1 INTO :XEMP_NO;
       OPEN C2;
       FETCH C2 INTO :XROWID;
       IF C2%FOUND THEN
          UPDATE EMP
          SET    . . . =  . . .
          WHERE  ROWID = :XROWID;
          KOUNTER = KOUNTER + 1;
          IF KOUNTER = 200 THEN
             COMMIT;
             KOUNTER = 0;
          END IF;
        END IF;
     END LOOP;
     CLOSE C1;
     CLOSE C2;
   END;
