Create Table Dynamically [message #37645] |
Mon, 18 February 2002 20:39 |
diaz
Messages: 58 Registered: October 2001
|
Member |
|
|
Hello
i want to have tables with the same fields but i wanted to make them dynamically created.
the field is like this :
id varchar2
name varchar2
joindate date
i want to make those fields in several tables cause it'll be easier for the next implementation..
so if the person is registered in some country then
the record of the person is in the table A_Country
if is in country B then the table is B_Country
can somebody tell me how to make this ?
thanks
|
|
|
Re: Create Table Dynamically [message #37646 is a reply to message #37645] |
Mon, 18 February 2002 23:15 |
tinel
Messages: 42 Registered: November 2001
|
Member |
|
|
Hi
I don't undersatand what you want. You want to dynamicaly create tables, or you want to dynamicaly insert persons into tables regarding the preson country? If you want to dynamicaly insert rows then use an if_then_else but if you need to dynamicaly creat tables here is a code that may help you:
declare
VCURSOR NUMBER;
VDUMMY VARCHAR2(100);
query_str varchar2(1000);
table_name varchar2(50);
begin
VCURSOR:=DBMS_SQL.OPEN_CURSOR;
VSTRINGFINAL:='create table ' || table_name || '( id varchar2(10),name varchar2(10),joindate date)';
DBMS_SQL.PARSE(VCURSOR, VSTRINGFINAL, DBMS_SQL.V7);
VDUMMY:=DBMS_SQL.EXECUTE(VCURSOR);
DBMS_SQL.CLOSE_CURSOR(VCURSOR);
end;
Bye
|
|
|
|