Question

I have a package that compiles fine in another 11g environment.
When I try to compile it in my XE 10g environment w/ a DBA User, I get the ORA-00942 error.

   FOR r IN (SELECT DISTINCT job_name jname
                        FROM dba_scheduler_jobs
                             ^
                       WHERE job_name LIKE p_job_prefix || '%')
   LOOP
      ...

When I execute a direct select on the table there is no issue.

   Select * from dba_scheduler_jobs;

Error Text:

   Line: 34 Column: 34  Error: PL/SQL: ORA-00942: table or view does not exist
Was it helpful?

Solution

In order to reference an object in a definer's rights stored procedure (the default), the owner of the procedure has to have direct access to the object. The privilege cannot be granted through a role, even a very powerful role like SYSDBA.

You probably want to grant the owner of this procedure the SELECT ANY DICTIONARY privilege

GRANT select any dictionary
   TO <<owner of procedure>>

You could also grant the privileges on each object (i.e. DBA_SCHEDULER_JOBS) individually but if you've already granted this user the SYSDBA privilege, you're probably not overly concerned with restricting grants.

Licensed under: CC-BY-SA with attribution
Not affiliated with StackOverflow
scroll top