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!

create table with timestamp

487726Jun 7 2007 — edited Jun 8 2007
Hello 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
Comments
Locked Post
New comments cannot be posted to this locked post.
Post Details
Locked on Jul 6 2007
Added on Jun 7 2007
5 comments
1,785 views