How to fix the Oracle error PLS-00487: Invalid reference to variable ‘string’?

In this post, you’ll learn more about the Oracle ErrorPLS-00487: Invalid reference to variable ‘string’ with the details on why you receive this error and the possible solution to fix it.

Oracle Error Description

PLS-00487: Invalid reference to variable ‘string’

Reason for the Error PLS-00487: Invalid reference to variable ‘string’

A variable was referenced in a way that is inconsistent with its datatype. For example, a scalar variable might have been mistakenly referenced as a record, as follows: DECLARE CURSOR emp_cur IS SELECT empno, ename, sal FROM emp; emp_rec emp_cur%ROWTYPE; my_sal NUMBER(7,2); BEGIN … total_sal := total_sal + my_sal.sal; — invalid …

How to fix the Error PLS-00487: Invalid reference to variable ‘string’ ?

You can fix this error in Oracle by following the below steps

Check the spelling of the variable name. Make sure the variable was declared properly and that the declaration and reference are consistent regarding datatype.