create table with timestamp
487726Jun 7 2007 — edited Jun 8 2007Hello All,
I am trying to create table within a procedure. All I am looking for is a way to create a table with timestamp (sysdate) appended to the table name.
Below is my attempt of doing so. Can you please help me out?
CREATE OR REPLACE PROCEDURE CREATE_TABLE1 AS
V_SYSDATE VARCHAR2(20);
V_TABLENAME VARCHAR2(40);
BEGIN
SELECT TRUNC(SYSDATE) into V_SYSDATE FROM DUAL;
SELECT CONCAT('ORDERS_BACKUP_',V_SYSDATE) into V_TABLENAME FROM DUAL;
EXECUTE IMMEDIATE 'CREATE TABLE ''||V_TABLENAME||'' as SELECT * from ORDERS
END;
Thanks,
TT