Insufficient privs when trying to execute an Oracle stored proc

I have created the stored procedure below. If I try to execute it, I am getting an insufficient priviledges error message.
Does anyone have any idea why?


CREATE OR REPLACE PROCEDURE SIMPLE
IS
 BEGIN
  EXECUTE IMMEDIATE 'CREATE TABLE ELIX (ID INT NULL);
  EXECUTE IMMEDIATE 'GRANT INSERT ON B1';
  EXECUTE IMMEDIATE 'INSERT INTO ELIX (ID) VALUES (1)';
END;

EXECUTE SIMPLE

Error starting at line : 3 in command -
EXECUTE SIMPLE
Error report -
ORA-01031: "insufficen
*Cause: An attempt was made to perform a database operation without the necessary privileges
LVL 2
brgdotnetcontractorAsked:
Who is Participating?

[Product update] Infrastructure Analysis Tool is now available with Business Accounts.Learn More

x
I wear a lot of hats...

"The solutions and answers provided on Experts Exchange have been extremely helpful to me over the last few years. I wear a lot of hats - Developer, Database Administrator, Help Desk, etc., so I know a lot of things but not a lot about one thing. Experts Exchange gives me answers from people who do know a lot about one thing, in a easy to use platform." -Todd S.

slightwv (䄆 Netminder) Commented:
You either don't have create table privileges or grant insert privileges.

For stored procedures the permissions need to be granted to the user that owns the procedure directly and not through a role.

Also:  You really shouldn't be creating tables and performing grants inside a stored procedure like that.  Oracle normally doesn't need to do that.
0
Geert GOracle dbaCommented:
it's not that "simple"

yer grant is wrong
grant insert on elix to B1

Open in new window


which user is executing what ?
0

Experts Exchange Solution brought to you by

Your issues matter to us.

Facing a tech roadblock? Get the help and guidance you need from experienced professionals who care. Ask your question anytime, anywhere, with no hassle.

Start your 7-day free trial
Mark GeerlingsDatabase AdministratorCommented:
Yes, Geert is correct.  Your syntax was wrong for the grant command.  But, the bigger problem here is what slightwv suggested: "You really shouldn't be creating tables and performing grants inside a[n Oracle] stored procedure."

Those actions may be common in SQL Server stored procedures, but that doesn't mean you should try to do things that way in Oracle.  Oracle and SQL Server are very different databases!
0
It's more than this solution.Get answers and train to solve all your tech problems - anytime, anywhere.Try it for free Edge Out The Competitionfor your dream job with proven skills and certifications.Get started today Stand Outas the employee with proven skills.Start learning today for free Move Your Career Forwardwith certification training in the latest technologies.Start your trial today
Oracle Database

From novice to tech pro — start learning today.