[Date Prev][Date Next][Thread Prev][Thread Next]
[Author Index]
[Date Index]
[Thread Index]
[SQR-USERS Info]
[SQRUG Home Page]
Use of bind variables
- Subject: Use of bind variables
- From: Brian Fitzpatrick <FITZPBM@KELLYSERVICES.COM>
- Date: Mon, 1 Jul 2002 13:46:44 -0400
- Importance: Normal
- Sensitivity:
I am looking into a possibility for optimizing an SQR report which is
running against an Oracle 8 database. The report is run lets say 500 times
initiated from a UNIX shell script - each time a parameter for a location
is passed to the report, and the report query is identical except for a
location number.
I have been building the query in a fashion such as this:
.
.
let $where_loc = 'where location = ''' $param '''
begin-select
last_name &lname
first_name &fname
from employee
[$where_loc]
As I understand it, because of the WHERE clause, the query is physically
different each time and will be reparsed by the query optimizer each time
the report is run. HOWEVER, I am told that if the query were to use a bind
variable like below, it would only be parsed once:
begin-select
last_name &lname
first_name &fname
from employee
where location = :loc
The question is: can this be done, and if so, how do I supply a value to
the bind variable :loc ? I've tried a begin-sql / end-sql block prior to
the report query, but the bind variable only exists for the duration of the
PL/SQL block.
Does this approach make sense for optimization, is this workable, will it
buy us much of a savings? Are there other areas I should be looking at
(indexing perhaps)? Any input is appreciated, thanks.