Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations IamaSherpa on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

DROP PUBLIC SYNONYM inside of stored procedure

Status
Not open for further replies.

redbadgers

Programmer
Aug 22, 2006
10
US
I have a stored procedure that accepts object type and object name as inputs then generates a DROP statement and exec immediate as dynamic SQL.
It works fine for all object types except PUBLIC SYNONYM.
When user with DBA role (such as "SYSTEM")invokes this procedure to drop a PUBLIC SYNONYM foo, it will yield insufficent privilege error on the "DROP PUBLIC SYNONYM foo" statement. The user with DBA role can execute the same "DROP PUBLIC SYNONYM foo" statement successfully on the SQL*Plus command line; but not from inside of the stored procedure.
Any Clue? It failed on both Oracle 9i and 10g.
Thanks!
Regards, Nancy
 
It's probably because your access is through a role and there are restrictions on what you can do in SPs through a role. Try granting the "Drop public synonym" privilege directly to the user who owns the SP.
 
The User that I used for testing has DBA role granted, and I checked specifically that DBA role on this Oracle instance still had DROP PUBLIC SYNONYM privilege.
This is what I have tried:
Grant DROP PUBLIC SYNONYM and DROP ANY SYNONYM system privileges to this user, then execute the procedure with attempt to "DROP PUBLIC SYNONYM foo" --- got the same insufficient privilege error. So I changed the DDL to "DROP SYNONYM PUBLIC.foo", still the same error.

Help?!
Regards, Nancy
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top