My Oracle Support Banner

An Owner With GAOP System Privilege Receives ORA-1031 or ORA-942 When Granting An Object Privilege (Doc ID 388774.1)

Last updated on APRIL 03, 2021

Applies to:

Oracle Database - Enterprise Edition - Version 9.2.0.1 to 10.2.0.3 [Release 9.2 to 10.2]
Oracle Database Cloud Schema Service - Version N/A and later
Oracle Database Exadata Express Cloud Service - Version N/A and later
Oracle Database Exadata Cloud Machine - Version N/A and later
Oracle Cloud Infrastructure - Database Service - Version N/A and later
Information in this document applies to any platform.
This problem can occur on any platform.

Symptoms

When SYSTEM user grants select on a table to another user with SQL*Plus , it works fine:  SYSTEM user has the GRANT ANY OBJECT PRIVILEGE system privilege .

SQL> CONNECT system/xxx
Connected.
SQL> grant SELECT, INSERT, UPDATE, DELETE on SCOTT.TEST TO X;
Grant succeeded.

1. Under 10g, when this statement is in a stored procedure, it returns "ORA-1031 - insufficient privilege".
2. Under 9i, it returns "ORA-00942: table or view does not exist "

SQL> CREATE OR REPLACE PROCEDURE system.def_grant_test

2 IS

3 cursor_handle INTEGER;

4 BEGIN

5 cursor_handle := DBMS_SQL.OPEN_CURSOR;

6 DBMS_SQL.PARSE(cursor_handle, 'GRANT SELECT, INSERT, UPDATE, DELETE on SCOTT.TEST TO X',
7 dbms_sql.native );

8 DBMS_SQL.CLOSE_CURSOR(cursor_handle);

9 END;

10 /

Procedure created.
SQL 9i> exec system.def_grant_test 
BEGIN system.def_grant_test; END;
*
ERROR at line 1:
ORA-00942: table or view does not exist
ORA-06512: at "SYS.DBMS_SYS_SQL", line 826
ORA-06512: at "SYS.DBMS_SQL", line 39
ORA-06512: at "SYSTEM.DEF_GRANT_TEST", line 6
ORA-06512: at line 1
SQL 10g> exec system.def_grant_test
BEGIN system.def_grant_test; END;

*
ERROR at line 1:
ORA-01031: insufficient privileges
ORA-06512: at "SYS.DBMS_SYS_SQL", line 906
ORA-06512: at "SYS.DBMS_SQL", line 39
ORA-06512: at "SYSTEM.DEF_GRANT_TEST", line 6
ORA-06512: at line 1

Cause

To view full details, sign in with your My Oracle Support account.

Don't have a My Oracle Support account? Click to get started!


In this Document
Symptoms
Cause
Solution
References


My Oracle Support provides customers with access to over a million knowledge articles and a vibrant support community of peers and Oracle experts.