Thursday, March 26, 2009

pl/sql cursor syntax

WHENEVER SQLERROR EXIT 2 ROLLBACK;
DECLARE
id NUMBER;
CURSOR c IS
SELECT ID FROM TAB;
BEGIN
OPEN c;
LOOP
FETCH c INTO id;

EXIT WHEN c%NOTFOUND;
END LOOP;
CLOSE c;

COMMIT;
END;
/

EXIT 1;

No comments: