Regarding Execute Immediate in stored procedure

旧街凉风 提交于 2020-02-04 01:28:09

问题


I am having the below statement from stored procedure. It's giving Insufficient Privileges. But If i run the create statement alone from the sql prompt it's creating table.

    execute immediate 'create table TEST_ABC(
                    NO_AC NUMBER(8) 
                    , ILL_PER VARCHAR2(15)
                    , INIT_C DATE
                    )';

What needs to be done to have priviliges to create table via execute immediate from stored procedure. Not sure how it's working from sql command prompt


回答1:


Procedures don't inherit privileges granted via a role. More info here. Please check if that's what happening to you.

One way to solve this problem is to grant "CREATE TABLE" privilege directly to the account that owns the procedure.




回答2:


Is the procedure created by the same user? If it is created by some one else and you have EXECUTE privilege alone, then the error is right (assuming the create procedure doesn't have AUTHID CURRENT USER clause).

Can you create any other table? If you can, then there is some issue. We would need more details to analyse.



来源:https://stackoverflow.com/questions/2360810/regarding-execute-immediate-in-stored-procedure

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!