How to fix the Oracle error PLS-00229: Attribute expression within SQL expression?

In this post, you’ll learn more about the Oracle ErrorPLS-00229: Attribute expression within SQL expression with the details on why you receive this error and the possible solution to fix it.

Oracle Error Description

PLS-00229: Attribute expression within SQL expression

Reason for the Error PLS-00229: Attribute expression within SQL expression

An attribute expression, such as SQL%NOTFOUND, was used in a SQL statement, but attribute expressions are allowed only in procedural statements.

How to fix the Error PLS-00229: Attribute expression within SQL expression ?

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

To workaround this limitation, assign the value of the attribute expression to a variable, then use the variable in the SQL statement. For example, replace the statement INSERT INTO audits VALUES (c1%ROWCOUNT, …); with the following statements: row_count := c1%ROWCOUNT; INSERT INTO audits VALUES (row_count, …);