how to resolve ORA-04042: procedure, function, package, or package body does not exist and ORA-00942: table or view does not exist

dba.stackexchange https://dba.stackexchange.com/questions/269184

Question

I am trying to grant EXECUTE and READ privilege on two tables to a user ktest1.

grant EXECUTE on SYS.KIR_DOKUMENT to ktest2;
grant READ on SYS.KIR_DOKUMENT to ktest2;

when i give grant execute i get below error

grant EXECUTE on SYS.KIR_DOKUMENT to ktest2
Error report -
ORA-04042: procedure, function, package, or package body does not exist
04042. 00000 -  "procedure, function, package, or package body does not exist"

when i give grant read i get below error

grant READ on SYS.KIR_DOKUMENT to ktest2
Error report -
ORA-00942: table or view does not exist
00942. 00000 -  "table or view does not exist"
*Cause:    

But i checked the status of the table in dba_objects and they are valid.

the type here is directory. enter image description here

Kindly advice.

Was it helpful?

Solution

That is not how you grant privileges on a directory.

SQL> create or replace directory KIR_DOKUMENT as '/tmp';

Directory created.

SQL> select owner, object_type, status from dba_objects where object_name = 'KIR_DOKUMENT';

OWNER
--------------------------------------------------------------------------------
OBJECT_TYPE             STATUS
----------------------- -------
SYS
DIRECTORY               VALID


SQL> grant read on SYS.KIR_DOKUMENT to bp;
grant read on SYS.KIR_DOKUMENT to bp
                  *
ERROR at line 1:
ORA-00942: table or view does not exist


SQL> grant execute on SYS.KIR_DOKUMENT to bp;
grant execute on SYS.KIR_DOKUMENT to bp
                     *
ERROR at line 1:
ORA-04042: procedure, function, package, or package body does not exist

Use the GRANT privilege ON DIRECTORY ... as:

SQL> grant read on directory SYS.KIR_DOKUMENT to bp;

Grant succeeded.

SQL> grant execute on directory SYS.KIR_DOKUMENT to bp;

Grant succeeded.

SQL>

OTHER TIPS

Is KIR_DOKUMENT a part of the data dictionary or did someone at your company create it? I assume that this is something that was written at your company. When the package gets executed, it is probably not using sys privileges. You probably have it set up to be run with invoker rights. If that is the case then ktest2 needs rights to do everything that the package is trying to do and it doesn't have select rights on at least one table in the KIR_DOCUMENT package. When asking a question you should provide more information like: version of Oracle, OS, 32/64 bit, and if this is a package any special options that the package uses. Options like invokers rights.

Licensed under: CC-BY-SA with attribution
Not affiliated with dba.stackexchange
scroll top