nikhilesh_chawla
asked on
creating table dynamically in oracle
Hi,
I have a PL/SQL block like below:
declare
v_char_date varchar2(20);
begin
v_char_date := to_char(sysdate, 'DDMONYYYYHH24MISS');
execute immediate 'create table v_char_date(col_name varchar2(20))';
end;
I want to create a table with name whatever i get in v_char_date variable.
But a table gets created with name "v_char_date".
Please help how to do that....
I have a PL/SQL block like below:
declare
v_char_date varchar2(20);
begin
v_char_date := to_char(sysdate, 'DDMONYYYYHH24MISS');
execute immediate 'create table v_char_date(col_name varchar2(20))';
end;
I want to create a table with name whatever i get in v_char_date variable.
But a table gets created with name "v_char_date".
Please help how to do that....
ASKER
No. It's not working.
Please try before answering.
Please try before answering.
ASKER CERTIFIED SOLUTION
membership
Create a free account to see this answer
Signing up is free and takes 30 seconds. No credit card required.
v_char_date varchar2(20);
begin
v_char_date := to_char(sysdate, 'DDMONYYYYHH24MISS');
execute immediate 'create table ' + v_char_date + '(col_name varchar2(20))';
end;