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!

SQLPLUS define variables for creating table.

tcodeJan 20 2010 — edited Jan 20 2010
I 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.
This post has been answered by Frank Kulash on Jan 20 2010
Jump to Answer
Comments
Locked Post
New comments cannot be posted to this locked post.
Post Details
Locked on Feb 17 2010
Added on Jan 20 2010
1 comment
5,911 views