473,385 Members | 2,013 Online
Bytes | Software Development & Data Engineering Community
Post Job

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 473,385 software developers and data experts.

Problem trying to write a PL/SQL routine that will generate a CREATE TABLE statement

Hello,

I am new to this forum, and I am a newbit in Oracle, I do have a background in MS Access, VBA, SQL server development and some Oracle backend development work.

I have been giving a task to dynamically create tables through code based on parameters in existing tables.

I will try to keep this short and to the point

The goal is to extract values from existing tables I will give an example of two tables to keep it simple

Table 1
Name: Obj_Type
Columns
obj_type Id obj_type_nm
1 Data_Design_Spec
2 Logical_Data_Model
3 Entity

Table 2
Name: Property
Columns
prpt_id prprt_nm
1 Source
2 Discoverable
3 Required

The parameters and logic for this is to use a where clause where 1 = would return Data_Design Spec as the NEW Table name and extract data from Table 2 and extract 1 = would be the property name in the new table which would be Source from Table 2

This has to be in some type of routine, I cannot manually use CREATE TABLE statement this has to be done in a SQL statement, also this routine will generate new tables based on values from EXISTING to inlcude data types and attributes. I will GLADLY pay someone through pay pal for the results or who can help me with this....thanks so much

Nana
Nov 28 '07 #1
4 2204
amitpatel66
2,367 Expert 2GB
HI Nana,

Welcome to TSDN!!

Please make seure you follow POSTING GUIDELINES when ever you post in this forum.

Thanks
MODERATOR
Nov 29 '07 #2
amitpatel66
2,367 Expert 2GB
Hello,

I am new to this forum, and I am a newbit in Oracle, I do have a background in MS Access, VBA, SQL server development and some Oracle backend development work.

I have been giving a task to dynamically create tables through code based on parameters in existing tables.

I will try to keep this short and to the point

The goal is to extract values from existing tables I will give an example of two tables to keep it simple

Table 1
Name: Obj_Type
Columns
obj_type Id obj_type_nm
1 Data_Design_Spec
2 Logical_Data_Model
3 Entity

Table 2
Name: Property
Columns
prpt_id prprt_nm
1 Source
2 Discoverable
3 Required

The parameters and logic for this is to use a where clause where 1 = would return Data_Design Spec as the NEW Table name and extract data from Table 2 and extract 1 = would be the property name in the new table which would be Source from Table 2

This has to be in some type of routine, I cannot manually use CREATE TABLE statement this has to be done in a SQL statement, also this routine will generate new tables based on values from EXISTING to inlcude data types and attributes. I will GLADLY pay someone through pay pal for the results or who can help me with this....thanks so much

Nana
Nana,

This forum is to help peoples with all their technical problems in different technologies.
We are glad to help peoples finding solution for their issues and we are not here to do business :)
So you can feel free and ask us anything in any technology.

So coming to your problem, What I understand from your explanation is:

If extract = 1 THEN new table should be created with name data_design_spec ie

Expand|Select|Wrap|Line Numbers
  1. -- This is just a pseudo code and not exact oracle source code
  2.  
  3. IF (extract = 1) THEN
  4. CREATE table data_design_spec;
  5.  
Now could you please explain the second part ie what you need to do with the "source" from table 2??
Nov 29 '07 #3
Nana,

This forum is to help peoples with all their technical problems in different technologies.
We are glad to help peoples finding solution for their issues and we are not here to do business :)
So you can feel free and ask us anything in any technology.

So coming to your problem, What I understand from your explanation is:

If extract = 1 THEN new table should be created with name data_design_spec ie

Expand|Select|Wrap|Line Numbers
  1. -- This is just a pseudo code and not exact oracle source code
  2.  
  3. IF (extract = 1) THEN
  4. CREATE table data_design_spec;
  5.  
Now could you please explain the second part ie what you need to do with the "source" from table 2??

Thanks for the response :)

This should be the end result of the new table structure

create table "OBJ_TYPE"
name varchar2(100) not null,
description varchar2(400) null,
and so forth.....

The ONLY columns that are to be hard coded are NAME and DESCRIPTION for each new table and the other columns are to be dynamically created based on the values in exisiting tables

Based on the EXISTING table structure I need to create NEW tables dynamically through code based on conditions of the EXISTING tables.

Example of the EXISTING tables are

Table 1
Name: Obj_Type
Columns
obj_type Id obj_type_nm
1 Data_Design_Spec
2 Logical_Data_Model
3 Entity

Table 2
Name: Property
Columns
prpt_id prprt_nm
1 Source
2 Discoverable
3 Required

Table 3
Name: Attribute
Columns
1. ERP_NO
2. Revision
3. Release
Datatype Column
1. String
Property Datatype Size
1. 2000

Example I would need to pull out from EACH table the column name based on condition EXAMPLE ERP_NO =1, Datatype Column, String =1 and Property Datatype Size =1 which would be 2000, Please note there are more data in the columns and fields, but I just wanted to include only a small portion of the data as an example.

the output would be something like this it would return a NEW TABLE STRUCTURE like the example below..based on SQL code.

Create table "Attribute"

Name varchar2(100)
Description varchar2(400)
Datatype String(20)
Nov 29 '07 #4
One more thing I forgot to mention the NEW table NAMES cannot be hard coded, the CODE would have to look in the EXISITNG Table and in the OBJ_type TABLE and look for the STRING "DATA DESIGN SPECIFICATION" and somehow with a SQL statement USE the create table function to NAME the new table "DATA DESIGN SPECIFICATION" and then the code will continue to loop through the rest of the tables and add column names based on the values in each table that is equal to based on the obj_id number 1 or 2 and so forth....
Nov 29 '07 #5

Sign in to post your reply or Sign up for a free account.

Similar topics

5
by: Raphael Gluck | last post by:
Hi I'm fairly new to coding in asp and i'm trying to create a simple if.. else... condition It's for asp web page, and is linked to my database, but i figured since it's a basic question, it...
6
by: Stephen Cook | last post by:
Having worked through the problems around enabling the document function using an XmlUrlResolver I started work on building a useful class to hide the intricacies. Trying to generalise the process...
2
by: Kent Lewandowski | last post by:
hi all, Recently I wrote some stored procedures using java jdbc code (admittedly my first stab) and then tried to implement the same within java packages (for code reuse). I encountered...
4
by: Prabhat | last post by:
How do I lock a particular record that one user has opened for editing? If I use the pessimistic type, can other users view the record (but not edit it) and return a message telling that another...
7
by: Dabbler | last post by:
I'm using an ObjectDataSource with a stored procedure and am getting the following error when trying to update (ExecuteNonQuery): System.Data.SqlClient.SqlException: Procedure or Function...
7
by: Jon Maz | last post by:
Hi, I have a MySql problem I hope someone can help me with. I'm trying to run an update on a linking table, the update is running into a Primary Key constraint violation, and in my workaround...
2
by: pelletier.thomas | last post by:
Hello everybody. I'm trying to code a very little OS. But I have a problem with the keyboard input: It show thechar + "~" :s Can you help me ? The source is there :...
1
by: daniel_xi | last post by:
Hi all, I am running a VS 2003 .NET project on my client machine (Win 2000 SP4, ..NET framework 1.1), running an ASP.NET application on a remote web server (Win 2000 Server, IIS 6.0, .NET...
12
by: =?Utf-8?B?R1ROMTcwNzc3?= | last post by:
Hi Guys, me again!!!! I've got a little recordset problem, basically I'm trying to build a jobs by email feature, so I have the following - Jobs by Email table which includes - category...
0
by: taylorcarr | last post by:
A Canon printer is a smart device known for being advanced, efficient, and reliable. It is designed for home, office, and hybrid workspace use and can also be used for a variety of purposes. However,...
0
by: aa123db | last post by:
Variable and constants Use var or let for variables and const fror constants. Var foo ='bar'; Let foo ='bar';const baz ='bar'; Functions function $name$ ($parameters$) { } ...
0
by: ryjfgjl | last post by:
If we have dozens or hundreds of excel to import into the database, if we use the excel import function provided by database editors such as navicat, it will be extremely tedious and time-consuming...
0
BarryA
by: BarryA | last post by:
What are the essential steps and strategies outlined in the Data Structures and Algorithms (DSA) roadmap for aspiring data scientists? How can individuals effectively utilize this roadmap to progress...
1
by: nemocccc | last post by:
hello, everyone, I want to develop a software for my android phone for daily needs, any suggestions?
1
by: Sonnysonu | last post by:
This is the data of csv file 1 2 3 1 2 3 1 2 3 1 2 3 2 3 2 3 3 the lengths should be different i have to store the data by column-wise with in the specific length. suppose the i have to...
0
marktang
by: marktang | last post by:
ONU (Optical Network Unit) is one of the key components for providing high-speed Internet services. Its primary function is to act as an endpoint device located at the user's premises. However,...
0
Oralloy
by: Oralloy | last post by:
Hello folks, I am unable to find appropriate documentation on the type promotion of bit-fields when using the generalised comparison operator "<=>". The problem is that using the GNU compilers,...
0
jinu1996
by: jinu1996 | last post by:
In today's digital age, having a compelling online presence is paramount for businesses aiming to thrive in a competitive landscape. At the heart of this digital strategy lies an intricately woven...

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.