Bind Variables
Posted: Tue 22 Jan 2008 18:53
Hello,
I am writing this because I cannot find anything under the keywords BIND VARIABLES in ODAC Help file.
I need to execute the SELECT query listed below, MANY MANY times with different parameters (right now it is listed with hardcoded literals like: ANNA BANANA ).
Normally I would use Bind Variables to avoid HARD PARSING and to avoid re-planning this query by the Oracle Server, each time it is executed.
...but ODAC help has no entry under "Bind Variables" so I need to ask you how to open this query multiple times with different parameters yet perform SOFT PARSING only (like with Bind Variables) ?
Note, that I do not want ODAC to concatenate the parameters into the SQL query string as literals and send it like that to the Oracle Server - that's wrong and very inefficient.
I want the Oracle Server to perform the variable substitiution (not ODAC) without replanning the query (a.k.a. softparsing). For an example see:
http://www.oracle-base.com/articles/mis ... iables.php
Also, which ODAC Class is best for doing this (TOraSQL, TOraQuery, TOraSmartQuery, TOraStoredProc, etc...) ?
I'm using Oracle 10g, ODAC v6.25, Delphi v7 in direct NET mode.
I am writing this because I cannot find anything under the keywords BIND VARIABLES in ODAC Help file.
I need to execute the SELECT query listed below, MANY MANY times with different parameters (right now it is listed with hardcoded literals like: ANNA BANANA ).
Normally I would use Bind Variables to avoid HARD PARSING and to avoid re-planning this query by the Oracle Server, each time it is executed.
...but ODAC help has no entry under "Bind Variables" so I need to ask you how to open this query multiple times with different parameters yet perform SOFT PARSING only (like with Bind Variables) ?
Note, that I do not want ODAC to concatenate the parameters into the SQL query string as literals and send it like that to the Oracle Server - that's wrong and very inefficient.
I want the Oracle Server to perform the variable substitiution (not ODAC) without replanning the query (a.k.a. softparsing). For an example see:
http://www.oracle-base.com/articles/mis ... iables.php
Also, which ODAC Class is best for doing this (TOraSQL, TOraQuery, TOraSmartQuery, TOraStoredProc, etc...) ?
I'm using Oracle 10g, ODAC v6.25, Delphi v7 in direct NET mode.
Code: Select all
SELECT
ENAM,FAMILIEN,GEBURT, i
FROM (
SELECT /*+ INDEX_RS_ASC(PATIENT ENAM_FAMI_IDDE) FIRST_ROWS */
row_number() OVER (PARTITION BY
NLSSORT("ENAM",'nls_sort=GERMAN'),NLSSORT("FAMILIEN",'nls_sort=GERMAN') ORDER BY
NLSSORT("ENAM",'nls_sort=GERMAN'),NLSSORT("FAMILIEN",'nls_sort=GERMAN'),ID) I,
ENAM,
FAMILIEN,
GEBURT
FROM PATIENT
WHERE NLSSORT("ENAM",'nls_sort=GERMAN')>=NLSSORT('ANNA','nls_sort=GERMAN') AND
(NLSSORT("ENAM",'nls_sort=GERMAN')>NLSSORT('ANNA','nls_sort=GERMAN') OR
NLSSORT("FAMILIEN",'nls_sort=GERMAN')>=NLSSORT('BANANA','nls_sort=GERMAN'))
ORDER BY NLSSORT("ENAM",'nls_sort=GERMAN'),NLSSORT("FAMILIEN",'nls_sort=GERMAN'),ID
) a
WHERE rownum=3 OR
NLSSORT("ENAM",'nls_sort=GERMAN')>NLSSORT('ANNA','nls_sort=GERMAN') OR
NLSSORT("FAMILIEN",'nls_sort=GERMAN')>NLSSORT('BANANA','nls_sort=GERMAN'));