When i execute stored procedure which contain EXECUTE IMMEDIATE
along with create table
statement inside the stored procedure then getting error while execute this Stored Proc.
Here is the Stored proc-
create or replace sp_exec
as
.......
v_mth date;
.......
begin
select to_char(add_months(current_DATE, -1), 'MON_YY') INTO v_mth FROM dual;
execute immediate 'create table tbl_mon_' ||v_mth|| ' as select ............... from ..... ';
end;
When I try to execute this Stored proc then getting error "Insufficient Privilege" at 2nd last line using this code to execute Stored Proc.
begin
sp_exec;
end;
then getting error which mentioned below:-
ORA-01031: Insufficient privilege
ORA-06512: at sp_exec line 11 --here line 11 mention for Execute immediate
ORA-06512: at line 2 -- here mention for sp_exec in the PLSQL block
I am working in the user schema itself so I've all types of privileges even CREATE TABLE
statement also. When i run outside the stored procedure (PL/SQL block) then dynamic table have been created.