Connecting Tech Pros Worldwide Forums | Help | Site Map

How to Create a Table Name from a value in an Existing Table?

Newbie
 
Join Date: Nov 2007
Location: Alexandria, VA
Posts: 5
#1: Nov 29 '07
Hello,

I posted yesterday a very complex question, but I did not receive a adequate answer so I decided to simplify things, and I will try to figure out the rest of the problem :).

Ok, I need to dynamically create about 4 tables through SQL code. The NEW table names need to be automatically poplulated and generated based on like a where clause...or something that will extract the value example "Design Specification" which is equal to ROW ID "4".

Example I have a Table Called "Objects" in that table it has 4 columns, one of the values in that table is called "Designed Specification" and a primary key COULMN NAMED "Obj_ID" which has a value of number 4. I would like to create a NEW table based on the EXISITNG table "Objects" and extract the NEW table names from the coumns in the table "Objects" and generate the new table name with CREATE table statement which will automatically populate the table name without manually typing in LIKE CREATE TABLE "Designed Specification".

Hopefully I explained this well :)

Thanks so much for your help

debasisdas's Avatar
Moderator
 
Join Date: Dec 2006
Location: Bangalore ,India
Posts: 7,511
#2: Nov 29 '07

re: How to Create a Table Name from a value in an Existing Table?


Can you kindly post what you have tried so far.
Newbie
 
Join Date: Nov 2007
Location: Alexandria, VA
Posts: 5
#3: Nov 29 '07

re: How to Create a Table Name from a value in an Existing Table?


This is what I am having troubl with,

I keep getting errors like missing parathesis and so forth.

This is what I am typing at the SQL prompt

DECLARE
X = OBJ_TYPE.OBJ_TYPE_NAME
CREATE TABLE X (
NAME (VARCHAR2(100),
DESCRIPTION(VARCHAR2(100)
WHERE OBJ_TYPE.OBJ_TYPE_ID = 4;

I need the code to extract the name "DESIGN SPECIFICATION" FROM EXISTING TABLE OBJ_TYPE - WHICH IS EQUAL TO X. this will be the table new name and the WHERE clause would pull this DESIGN SPECIFICATION from ROW 4 and that will CREATE a NEW TABLE called DESIGN SPECIFICATION....I know the code is wrong but hopefully you can work with the syntax...:)
Reply