DBAsupport.com Forums - Powered by vBulletin
Results 1 to 3 of 3

Thread: what are the privileges to be granted to execute a procedure?

  1. #1
    Join Date
    Dec 2000
    Posts
    95

    Question which privilege to be granted to execute a procedure(dynamic sql is used) ?

    Hi Friends,

    I created a procedure as follows

    SQL> create procedure proctab (table_name in varchar2,column1 in varchar2,column2 in varchar2)
    2 as
    3 begin
    4 execute immediate 'create table ' || table_name || ' (' || column1 || ' varchar2(10),'
    5 || column2 || ' varchar2(10))';
    6 end;
    7 /

    Procedure created.

    when i am trying to execute the above procedure its giving the following error


    SQL> execute proctab('test10','name','city');
    BEGIN proctab('test10','name','city'); END;

    *
    ERROR at line 1:
    ORA-01031: insufficient privileges
    ORA-06512: at "SYSTEM.PROCTAB", line 4
    ORA-06512: at line 1


    i connected as system/manager
    i think "system" has all(create procedure , execute any procedure) the privileges. but the above statement giving the error that " insufficient privileges .

    is there any special privileges to be granted when we are using the dynamic sql ? Because i have used dynamic sql in the procedure.

    please tell me what are the additional privileges that i have to grant to system? and how to grant the privileges to "system" . because to grant the privileges first we have to connect to the database know, so by what user shall i connect to the datbase to grant the privileges to "system"(system has the dba role) .



    please help me


    regards

    SrinivasM



    [Edited by srinivasm on 01-09-2001 at 10:25 PM]

  2. #2
    Join Date
    Feb 2000
    Location
    Washington DC
    Posts
    1,843
    EXECUTE ANY PROCEDURE system privilege can execute any procedure in the database

  3. #3
    Join Date
    Dec 2000
    Location
    Ljubljana, Slovenia
    Posts
    4,439
    It is not the problem with the privileges of the user who is executing the procedure. As long as he has permision to execute this procedure, either through role or directly, he is OK.

    The problem is with the privileges of the owner of the procedure, in this case user SYSTEM. Although he has almost unlimited privileges on the database, thos privileges has been granted to him through role (DBA role). Hovewer roles are disabled during execution of the procedures, hence insuficient privileges to create the table.

    Simply GRANT CREATE TABLE TO SYSTEM (connected as any user with DBA role, it can even be SYSTEM himself), recompile the procedure and you'll be able to execute this procedure.

    Bevare, no matter which user will be executing this procedure, table will always be created under schema SYSTEM, that is undret the schema who owns the procedure.

    HTH,
    Jurij Modic
    ASCII a stupid question, get a stupid ANSI
    24 hours in a day .... 24 beer in a case .... coincidence?

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •  


Click Here to Expand Forum to Full Width