Skip to Main Content

SQL & PL/SQL

Announcement

For appeals, questions and feedback about Oracle Forums, please email oracle-forums-moderators_us@oracle.com. Technical questions should be asked in the appropriate category. Thank you!

PL/SQL - Using a variable as a table name

user10768199Nov 8 2011 — edited Nov 8 2011
I have a procedure like this -

PROCEDURE insert_food IS

BEGIN

INSERT INTO food_table
SELECT *
FROM fruit_table;

END insert_food;


So this proceudre would insert all the records in the 'fruit_table' into the 'food_table'.

Would there be any way to store the 'fruit_table' as a variable and use that in the script?

Something like -



PROCEDURE insert_food IS

table_name varchar(11) := 'fruit_table';

BEGIN

INSERT INTO food_table
SELECT *
FROM table_name;

END insert_food;


Any help would be great!
Comments
Locked Post
New comments cannot be posted to this locked post.
Post Details
Locked on Dec 6 2011
Added on Nov 8 2011
3 comments
6,815 views