PL/SQL - Using a variable as a table name
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!