PLS-00394 wrong number of values in the INTO list of a FETCH statement
Oracle SQL Error: PLS-00394: wrong number of values in the INTO list of a FETCH statement
Cause:
The number of variables in the INTO clause of a FETCH statement does not match the number of columns in the cursor declaration.
Solution:
Change the number of variables in the INTO clause or the number of columns in the cursor declaration so that the numbers match.
Example:
DECLARE CURSOR c1 IS SELECT * FROM books; rec BOOKS.name%TYPE; BEGIN OPEN c1; LOOP FETCH c1 INTO rec; EXIT WHEN c1%NOTFOUND; DBMS_OUTPUT.PUT_LINE(rec.NAME); END LOOP; CLOSE c1; END;
Output:
ORA-06550: line 7, column 2:
PLS-00394: wrong number of values in the INTO list of a FETCH statement
Correct
DECLARE CURSOR c1 IS SELECT * FROM books; --rec BOOKS.name%TYPE; rec BOOKS%ROWTYPE; BEGIN OPEN c1; LOOP FETCH c1 INTO rec; EXIT WHEN c1%NOTFOUND; DBMS_OUTPUT.PUT_LINE(rec.NAME); END LOOP; CLOSE c1; END;
Output:
anonymous block completed