use value of one variable as a name of the second variable [message #39652] |
Wed, 31 July 2002 04:51 |
OAK
Messages: 2 Registered: July 2002
|
Junior Member |
|
|
I have three variables: x1,x2,x3
x1 := 'a';
x2 := 'x1';
x3
I would like to now if I can assign value of variable x1 to x3 with help of variable x2.
Something like that:
x3 := ????? x2 and I want the value of variable x3 to be 'a'
Has anyone any idea?
|
|
|
|
Re: use value of one variable as a name of the second variable [message #39667 is a reply to message #39652] |
Thu, 01 August 2002 00:32 |
Wijnand
Messages: 11 Registered: March 2002
|
Junior Member |
|
|
select
first,
second,
decode(second,'unlikely value',second,first) third,
decode(to_char(sysdate,'yyyymmdd'),'20020722', 'my birthday!','not my birthday') fourth
from
(select '&var1' first,'&var2' second from dual)
OUTPUT (sorry for Dutch text when asked for vars)
SQL> /
Voer waarde voor var1 in: nr1
Voer waarde voor var2 in: nr2
FIR SEC THI FOURTH
nr1 nr2 nr1 not my birthday
This proves you can change variables and even meke them dependant of a date or other condition.
You can set the column headings off and spool to a new SQL. var1 would then be 'select whatever from table'
and var2 'where condition = wharever you wish'
Every time when run, the second SQL (that you create by spooling) will be different depending on the conditions you put in the first.
This way you create a SQL that only operates on your birthday
|
|
|