/* ----- 41c.sql -----*/ /* Example of using a cursor with explicit fetch */ set echo on; drop table TEST; create table TEST (NR1 number(3), NR2 number(3)); begin -- insert values into table TEST for i in 1..20 loop insert into TEST values(null,i); end loop; commit; end; / declare x number(4) := 0; cursor T_CUR is select * from TEST order by NR2 desc for update of NR1; T_REC TEST%ROWTYPE; begin open T_CUR; loop fetch T_CUR into T_REC; exit when T_CUR%NOTFOUND; update TEST set NR1 = x where current of T_CUR; x := x + 1; end loop; close T_CUR; commit; end; / select * from TEST;