web analytics

Creating Table dynamically in Oracle Procedure

You may also like...

1 Response

  1. sm42737 says:

    Hi,

    I want to rename and recreate a table as given below, the code is working fine.
    But i want one modifications as- IF THE TABLE (M_BYP_20120123) ALREADY EXIST THEN STOP THERE AND EXIT.

    create or replace
    procedure prc_drp_crt is
    begin
    Execute immediate ‘rename ‘|| ‘M_BYP’ ||’ to’||’ M_BYP_’||to_char(sysdate-1,’YYYYMMDD’);
    Execute immediate ‘create table ‘||’M_BYP ‘||’as ‘|| ‘select * from M_BYP_’||to_char(sysdate-1,’YYYYMMDD’)|| ‘ where 1=2’;
    end prc_drp_crt;

Leave a Reply

%d bloggers like this: