PL/SQL: ORA-00942: table or view does not exist

The problem

I was compiling a package with a SQL query embedded within the package body. I really couldn’t understand why the package was not compiling because the query, when run outside of the package and as the same user, was running successfully. The error that I was getting was a generic and usually very simple error to fix:

PL/SQL: SQL Statement ignored
PL/SQL: ORA-00942: table or view does not exist

The Cause

The user that I was compiling this package as had the necessary grants to select from the table and could see it, but unfortunately it turns out that when running a SQL query within a PL\SQL package the grants have to be explicitly granted. In my case, the grants were made through a role.

The Solution

I granted the necessary grants explicitly and then compiled the package which worked without any problems.

Like it, share it...

Category: PL/SQL

Related Posts

Leave a Reply

Your email address will not be published. Required fields are marked *