PLS-00206 %TYPE must be applied to a variable, column, field or attribute, not to

PLS-00206 %TYPE must be applied to a variable, column, field or attribute, not to

Oracle SQL Error: PLS-00206 %TYPE must be applied to a variable, column, field or attribute, not to “string”

Cause:

The program object declared using the %TYPE datatype attribute is not of the appropriate class. It must be a variable, column, record component, subprogram formal parameter, or other object to which values can be assigned.

Solution:

Declare an object of the appropriate class or define the datatype in another way (use %ROWTYPE).

Example:

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

Output:

ORA-06550: line 2, column 8:
PLS-00206: %TYPE must be applied to a variable, column, field or attribute, not to “BOOKS”

Correct

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

Output:

anonymous block completed