Monday, July 23, 2012

Create table at Run Time

create or replace procedure p1
as
begin
execute immediate 'create table table_name (column_name datatype)';
end;
/



SQL> exec p1;
ORA-01031: insufficient privileges
ORA-06512: at "schema.procedure", line 4 / line 7
ORA-06512: at line 1

oops error !!!!!!


Don't worry

Just add one line to your procedure:



create or replace procedure p1
AUTHID CURRENT_USER
as
begin
execute immediate 'create table table_name (column_name datatype)';
end;
/

SQL> exec p1;
PL/SQL procedure successfully completed.

No comments:

Post a Comment

web stats