SQLPLUS define variables for creating table.
tcodeJan 20 2010 — edited Jan 20 2010I am doing the following in SQLPLUS
define l_date = to_char(sysdate,'yyyy')
define l_name = "'mytable'"
define l_tn = &l_name||&l_date
SQL> select &l_name||&l_date from dual;
old 1: select &l_name||&l_date from dual
new 1: select 'mytable'||to_char(sysdate,'yyyy') from dual
'MYTABLE'||
-----------
mytable2010
But when I use in this way I don't get YEAR.
SQL> select '&l_tn' from dual;
old 1: select '&l_tn' from dual
new 1: select 'mytable' from dual
'MYTABL
-------
mytable
I want to create table in sqlplus using the following command:
create table &l_tn(x number)
Please let me know what I am doing wrong here.