Go Premium for a chance to win a PS4. Enter to Win

x
?
Solved

execute immediate issue

Posted on 2007-11-21
6
Medium Priority
?
1,314 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 2000 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
Concerto Cloud for Software Providers & ISVs

Can Concerto Cloud Services help you focus on evolving your application offerings, while delivering the best cloud experience to your customers? From DevOps to revenue models and customer support, the answer is yes!

Learn how Concerto can help you.

 
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

VIDEO: THE CONCERTO CLOUD FOR HEALTHCARE

Modern healthcare requires a modern cloud. View this brief video to understand how the Concerto Cloud for Healthcare can help your organization.

Question has a verified solution.

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

Working with Network Access Control Lists in Oracle 11g (part 2) Part 1: http://www.e-e.com/A_8429.html Previously, I introduced the basics of network ACL's including how to create, delete and modify entries to allow and deny access.  For many…
Have you ever had to make fundamental changes to a table in Oracle, but haven't been able to get any downtime?  I'm talking things like: * Dropping columns * Shrinking allocated space * Removing chained blocks and restoring the PCTFREE * Re-or…
This video shows how to set up a shell script to accept a positional parameter when called, pass that to a SQL script, accept the output from the statement back and then manipulate it in the Shell.
This video shows how to Export data from an Oracle database using the Datapump Export Utility.  The corresponding Datapump Import utility is also discussed and demonstrated.
Suggested Courses

772 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