commit and rollback in loop

From: Luc Gyselinck <Luc.Gyselinck_at_village.uunet.be>
Date: Tue, 10 Nov 1998 23:11:38 +0100
Message-ID: <72adtj$fc9$1_at_xenon.inbe.net>



I have the following stored procedure:

procedure x is
 cursor c is
  select * from table
  order by col_id;
begin
 for r in c loop
   <do stuff>
   if <any error> then
    rollback;
    update table set <...> where col_id = r.col_id;     commit;
  else
    delete table where col_id = r.col_id;     commit;
  end if;
 end loop;
end;

My questions are :
does this construct guarantees that I handle all rows in the order of the col_id column?
is an index on col_id mandatory to make this work?

In general, what are the rules (what is forbidden) when using commit and rollback in a cursor loop? Received on Tue Nov 10 1998 - 23:11:38 CET

Original text of this message