DECLARE i number; j number; BEGIN i := 1; j := 0; select count(*) into j from table where scenaio = 0 ; loop exit when i > j ; update table set scenaio = 1 where scenaio = 0 and rownum <= 5000; i := i + 5000; commit; END loop; END;