Home » RDBMS Server » Server Administration » Can I reuse the parameters in the SQL?
Can I reuse the parameters in the SQL? [message #371412] Sun, 15 October 2000 22:59 Go to next message
Angus
Messages: 18
Registered: October 2000
Junior Member
Can I reuse the parameters in the SQL.
for example,I would like to count how many employees was employed during a period.
I issues the following statement, but is doesn't work. both of parameter &1 are reference to the same value as well as parameter &2
How can I do that? Could you give me some advices? Thank You !

Here is the statement:

select count(*) || ' employees was hired during ' || to_date('&1', 'YYYYMMDD') || ' and ' || to_date('&2', 'YYYYMMDD')
from emp
where to_char(hiredate, 'YYYYMMDD') between '$1' and '$2';
Re: Can I reuse the parameters in the SQL? [message #371415 is a reply to message #371412] Mon, 16 October 2000 02:21 Go to previous message
Sandeep Deshmukh
Messages: 13
Registered: October 2000
Junior Member
Angus,

Yeah..you can reuse the parameters.See the query below :

select count(*) || ' employees was hired during ' || '&&1' || ' and ' ||'&&2'
description
from emp
where trunc(hire_date) between to_date('&&1','DD/MM/RRRR')
and to_date('&&2','DD/MM/RRRR')
/

Here I used substitution parameters as &&,which will be asked by your query in first go.And later on you have to specifically undefine them to have different value of 1 and 2.Otherwise will keep the sam evalue.
command is undefine 1

Try it,it has to work.

Sandeep
Previous Topic: sequences
Next Topic: Re: WHERE IS THE CONTROLFILE'S TRACE SQL?
Goto Forum:
  


Current Time: Wed Apr 24 02:06:53 CDT 2024