Home » SQL & PL/SQL » SQL & PL/SQL » use value of one variable as a name of the second variable
use value of one variable as a name of the second variable [message #39652] Wed, 31 July 2002 04:51 Go to next message
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 #39654 is a reply to message #39652] Wed, 31 July 2002 05:15 Go to previous messageGo to next message
Mahesh Rajendran
Messages: 10707
Registered: March 2002
Location: oracleDocoVille
Senior Member
Account Moderator
Pls dont repeat the postings in all boards!
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 Go to previous message
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
Previous Topic: Contraints - not so simple
Next Topic: user_users and dba_users
Goto Forum:
  


Current Time: Thu Apr 25 05:39:52 CDT 2024