WHERE CURRENT OF raising and invalid rowid error
You have your exit
in the wrong place; it should be straight after the fetch
. You are processing your six real rows properly, but then you have a seventh fetch - after which %notfound
will be true
- so there is no 'current' row to update. You need to exit before you try to do anything with that invalid row.
BEGIN OPEN c1; LOOP FETCH c1 INTO c_id, c_name, c_age; EXIT WHEN c1%NOTFOUND; UPDATE customers SET age = age + 1 WHERE CURRENT OF c1; dbms_output.put_line( c_id || ' ' || c_name || ' ' || c_age ); END LOOP; CLOSE c1;END;
Hopefully this is just an exercise, as it's not a very efficient way to do the updates.