This is my question
Can we create tables using stored procedures?
I treid like this but it din't work
SQL> create procedure create_table (table_name in varchar2,column1 in varchar2,column2 in varchar2)
as
2 begin
3 create table table_name (column1 varchar2(10),column2 varchar2(10));
4 end;
5 /
when i execute the above statement its showing the following waring
" Warning: Procedure created with compilation errors. "
You might be able to do it with the DBMS_SQL package. I think you could use the PARSE and EXECUTE procedures by putting your create statement(s) into a varchar and passing it to with an open cursor. Sorry this is so vague, but I'm not sure of the syntax. Hope this provides some direction.
In 8.0 you can use procedure exec_ddl_statement in package dbms_utility for ddl statements:
procedure create_table (table_name in varchar2,column1 in varchar2,column2 in varchar2)
as
begin
dbms_utility.exec_ddl_statement('create table '||table_name||' ('||column1|| ' varchar2(10), '|| column2 ||' varchar2(10))');
end;
YES, you can create table using stored procedures using SQL_DBMS package. Check out the functions inside them, sql_parse, sql_execute
Regards
Ganesh .R
A Winner never Quits, A Quitter never Wins
Ganesh .R
Bookmarks