Skip to Main Content

SQL & PL/SQL

Announcement

For appeals, questions and feedback about Oracle Forums, please email oracle-forums-moderators_us@oracle.com. Technical questions should be asked in the appropriate category. Thank you!

Giving grants through a procedure

amardeep.sidhuMay 5 2008 — edited May 5 2008

Hi guys

I have one schema (lets say XYZ) and there are some tables in it. I have created another user TESTING in the database.

I wrote a procedure GRANT_SELECT in the SYSTEM schema (as the procedure, by default will execute with the owner's rights...right ?) through which TESTING user can get the SELECT privilege on objects of XYZ. Then i granted execute on procedure to TESTING user.

create or replace procedure grant_select(p_object in varchar2,
                                         p_owner  in varchar2) is
  v_String varchar2(500);
begin
  v_String := 'grant select on ' || p_owner || '.' || p_object ||
              ' to testing';
execute immediate v_string;
--dbms_output.put_line(v_string);
end grant_select;

Now when i am trying to execute this from TESTING user, it gives:

ORA-01031: insufficient privileges
ORA-06512: at "SYSTEM.GRANT_SELECT", line 7
ORA-06512: at line 1

Is it not executing with SYSTEM rights ? or i am mis-interpreting the things ?

Thanks

Amardeep Sidhu

Comments
Locked Post
New comments cannot be posted to this locked post.
Post Details
Locked on Jun 2 2008
Added on May 5 2008
10 comments
724 views