PLS-00310 with %ROWTYPE attribute, must name a table, cursor or cursor-variable

PLS-00310 with %ROWTYPE attribute, must name a table, cursor or cursor-variable

Oracle SQL Error: PLS-00310 with %ROWTYPE attribute, ‘string’ must name a table, cursor or cursor-variable

Cause:

The %ROWTYPE attribute must be applied to an identifier declared as a cursor, cursor variable, or database table. This error occurs when %ROWTYPE follows some identifier that has not been so declared.

Solution:

Change the declaration or do not apply the %ROWTYPE attribute to the identifier.

Example:

DECLARE
	v_name BOOKS.name%ROWTYPE;
BEGIN
	SELECT name INTO v_name 
	FROM books WHERE id=3;
	DBMS_OUTPUT.PUT_LINE(v_name);
END;

Output:

ORA-06550: line 2, column 9:
PLS-00310: with %ROWTYPE attribute, ‘BOOKS.NAME’ must name a table, cursor or cursor-variable

Correct

DECLARE
	v_name BOOKS.name%TYPE;
BEGIN
	SELECT name INTO v_name 
	FROM books WHERE id=3;
	DBMS_OUTPUT.PUT_LINE(v_name);
END;

Output:

anonymous block completed