PL/SQL Where current of

... WHERE CURRENT OF cursor

WHERE CURRENT is used as a reference to the current row when using a cursor to UPDATE or DELETE the current row.

The cursor must be based on SQL that selects 'FOR UPDATE'

e.g.

DECLARE
   CURSOR trip_cursor IS
      SELECT
           bt_id_pk,
           bt_duration
      FROM
           business_trips
      WHERE
           bt_id_pk = 23
      FOR UPDATE OF bt_id_pk, bt_duration;
BEGIN
   FOR trip_record IN trip_cursor LOOP
     UPDATE business_trips
     SET bt_duration = 5
     WHERE CURRENT OF trip_cursor;
   END LOOP;
   COMMIT;
END;

Related:


© Copyright SS64.com 1999-2014
Some rights reserved