Home » SQL & PL/SQL » SQL & PL/SQL » Create Table Dynamically
Create Table Dynamically [message #37645] Mon, 18 February 2002 20:39 Go to next message
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 Go to previous messageGo to next message
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
Re: Create Table Dynamically [message #37651 is a reply to message #37645] Tue, 19 February 2002 03:03 Go to previous message
Milind S Deobhankar
Messages: 33
Registered: January 2002
Member
Hi,

Do you want to create the temp table in SGA and remove after the use or use want to create the table Dynamically using the bind variable. The things you had mention does not specify your requirement.
Previous Topic: Trigger gives error
Next Topic: searching for a ' quote through SQL
Goto Forum:
  


Current Time: Thu Mar 28 08:01:39 CDT 2024