Link to home
Create AccountLog in
Avatar of nikhilesh_chawla
nikhilesh_chawlaFlag for India

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....
Avatar of orcic
orcic

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;
Avatar of nikhilesh_chawla

ASKER

No. It's not working.
Please try before answering.
ASKER CERTIFIED SOLUTION
Avatar of orcic
orcic

Link to home
membership
Create a free account to see this answer
Signing up is free and takes 30 seconds. No credit card required.
See answer