Welcome to Experts Exchange

Add your voice to the tech community where 5M+ people, just like you, are talking about what matters.

  • Help others & share knowledge
  • Earn cash & points
  • Learn & ask questions
Solved

execute immediate issue

Posted on 2007-11-21
6
1,307 Views
Last Modified: 2013-12-07
1  CREATE OR REPLACE PROCEDURE X AS
 2  BEGIN
 3   begin
 4  execute immediate 'CREATE TABLE XYZ NOLOGGING AS SELECT * FROM COMMITMENTS_EXTRACT_BYUSER ';
 5  end;
 6  EXECUTE IMMEDIATE 'DROP TABLE COMMITMENTS_EXTRACT_BYUSER';
 7  EXECUTE IMMEDIATE 'RENAME XYZ TO COMMITMENTS_EXTRACT_BYUSER';
 8* END X;
 9  /

rocedure created.

QL> EXECUTE X;
EGIN X; END;


RROR at line 1:
ORA-01031: insufficient privileges
ORA-06512: at "VDB_OWNER.X", line 4
ORA-06512: at line 1


But the below code is working

 1  DECLARE
 2  BEGIN
 3   execute immediate 'CREATE TABLE XYZ NOLOGGING AS SELECT * FROM COMMITMENTS_EXTRACT_BYUSER WHER
 4  EXECUTE IMMEDIATE 'DROP TABLE COMMITMENTS_EXTRACT_BYUSER';
 5  EXECUTE IMMEDIATE 'RENAME XYZ TO COMMITMENTS_EXTRACT_BYUSER';
 6* END;
 7  /

PL/SQL procedure successfully completed.

Why is my initial code not working,how can i achieve the results using my initial code.
Rgds,
Suhin
0
Comment
Question by:suhinrasheed
6 Comments
 
LVL 23

Expert Comment

by:Ashish Patel
ID: 20326632
Your user is not having permissions to execute procedure i guess. Please gran all previlages to user VDB_OWNER.X
0
 

Author Comment

by:suhinrasheed
ID: 20326671
i have created the procedure in VDB_OWNER and the schema has privileges to execute procedures,but the issue is there
0
 
LVL 27

Accepted Solution

by:
sujith80 earned 500 total points
ID: 20326672
Try to give the "CREATE TABLE" privilege explicitly to your user as a DBA.

like

grant CREATE TABLE to VDB_OWNER
/
0
PRTG Network Monitor: Intuitive Network Monitoring

Network Monitoring is essential to ensure that computer systems and network devices are running. Use PRTG to monitor LANs, servers, websites, applications and devices, bandwidth, virtual environments, remote systems, IoT, and many more. PRTG is easy to set up & use.

 
LVL 23

Expert Comment

by:Ashish Patel
ID: 20326674
check for permission for creating table too which is at line 4
0
 
LVL 28

Expert Comment

by:Naveen Kumar
ID: 20326802
when running something from sql prompt, use set serveroutput on
and also dbms_output.put_line(..) to see where the error is coming.

Also have an exception handling section whether it is a procedure or anonymous block, and write some text to the screen or debug table in the exception handler which can print/insert the SQLCODE and SQLERRM.

Thanks
0
 
LVL 32

Expert Comment

by:awking00
ID: 20327975
Try adding the following to your procedure and see what happens
CREATE OR REPLACE PROCEDURE X
AUTHID CURRENT_USER  ==>This syntax
AS
BEGIN
...
0

Featured Post

Free Tool: IP Lookup

Get more info about an IP address or domain name, such as organization, abuse contacts and geolocation.

One of a set of tools we are providing to everyone as a way of saying thank you for being a part of the community.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

Suggested Solutions

Title # Comments Views Activity
sort a spool into file output in oracle 1 44
selective queries 7 37
Help on model clause 5 37
any step by steps guide on how to install Oracle 12c on Windows 10 8 54
Background In several of the companies I have worked for, I noticed that corporate reporting is off loaded from the production database and done mainly on a clone database which needs to be kept up to date daily by various means, be it a logical…
Using SQL Scripts we can save all the SQL queries as files that we use very frequently on our database later point of time. This is one of the feature present under SQL Workshop in Oracle Application Express.
Video by: Steve
Using examples as well as descriptions, step through each of the common simple join types, explaining differences in syntax, differences in expected outputs and showing how the queries run along with the actual outputs based upon a simple set of dem…
This video shows syntax for various backup options while discussing how the different basic backup types work.  It explains how to take full backups, incremental level 0 backups, incremental level 1 backups in both differential and cumulative mode a…

789 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question