-
Help in a simple procedure
i want to develope a pl/sql procedure that will create an empty table. below the code that i wrote but it is not working
Code:
create procedure myProc AS
declare
first_name VARCHAR(15),
last_name VARCHAR(15),
salary FLOAT(8,2),
city VARCHAR(10),
description VARCHAR(15)
BEGIN
EXECUTE IMMEDIATE ('create table employee_table');
END;
-
why did you think it would work - that isnt a correct create table statement
-
Thank you sir for pointing that out. I m very new to Sql procedure can you tell/show me the correct syntax for the above code
-
create table
( first_name VARCHAR(15),
last_name VARCHAR(15),
salary FLOAT(8,2),
city VARCHAR(10),
description VARCHAR(15)
);
lucky
-
u didnt get me i want to know how to create empty table using sql procedure and not using sql query....
-
Well... your procedure has to:
1) Be able to get all data it needs -owner, table_name, column_names, column_attributes, etc - as input parameters
2) Build a proper create table statement on the fly -dynamic sql
3) Execute such an statement
Pablo (Paul) Berzukov
Author of Understanding Database Administration available at amazon and other bookstores.
Disclaimer: Advice is provided to the best of my knowledge but no implicit or explicit warranties are provided. Since the advisor explicitly encourages testing any and all suggestions on a test non-production environment advisor should not held liable or responsible for any actions taken based on the given advice.
-
 Originally Posted by mahajanakhil198
create table
( first_name VARCHAR(15),
last_name VARCHAR(15),
salary FLOAT(8,2),
city VARCHAR(10),
description VARCHAR(15)
);
what the hell is that?
-
create table employee_table
( first_name VARCHAR(15),
last_name VARCHAR(15),
salary number(8,2),
city VARCHAR(10),
description VARCHAR(15)
);
or
BEGIN
EXECUTE IMMEDIATE '
create table employee_table
(
first_name VARCHAR(15),
last_name VARCHAR(15),
salary number(8,2),
city VARCHAR(10),
description VARCHAR(15)
)';
END;
or
create procedure myProc AS
BEGIN
EXECUTE IMMEDIATE '
create table employee_table
(
first_name VARCHAR(15),
last_name VARCHAR(15),
salary number(8,2),
city VARCHAR(10),
description VARCHAR(15)
)';
END;
Lots of ways there. You can't just give table structure that way.
Posting Permissions
- You may not post new threads
- You may not post replies
- You may not post attachments
- You may not edit your posts
-
Forum Rules
|
Click Here to Expand Forum to Full Width
|