Oracle FAQ Your Portal to the Oracle Knowledge Grid
HOME | ASK QUESTION | ADD INFO | SEARCH | E-MAIL US
 

Home -> Community -> Mailing Lists -> Oracle-L -> RE: ** SQL WHERE clause order

RE: ** SQL WHERE clause order

From: Naveen, Nahata (IE10) <Naveen.Nahata_at_honeywell.com>
Date: Tue, 04 Nov 2003 21:59:25 -0800
Message-ID: <F001.005D5951.20031104215925@fatcity.com>


If the query is a part of the cursor then you can simply write the cursor query as:  

    SELECT emp_id
    FROM emp
   WHERE dept = :dept
     AND salary > :min_sal;  

and then open the cursor only if the condition "select_sen_emp_chk_first = 'Y'" evaluates to true  

e.g.  

IF select_sen_emp_chk_first = 'Y' THEN  

    FOR c IN your_cursor LOOP

Regards
Naveen  

-----Original Message-----
Sent: Wednesday, November 05, 2003 3:54 AM To: Multiple recipients of list ORACLE-L

Wolfgang,

    I want it (select_sen_emp_chk_first) evaluated first because it is a prog (PL/SQL) variable. I assume it would be faster than others. Since : It does not have to go to table data to evaluate that like it would have to for dept or salary. Thank You

Wolfgang Breitling <breitliw_at_centrexcc.com> wrote:

Why do you want a certain predicate evaluated first?

At 02:34 PM 11/4/2003, you wrote:
>Hi,
> In a SQL statement I want a certain where clause to be done first. Is
> it enough to list it first as follows or do I (and can I) do something
> else to make it get checked first before other WHERE/AND clause are
> looked at. Thanks :
>
>SELECT emp_id FROM emp
>WHERE select_sen_emp_chk_first = 'Y'
>AND dept = :dept
>AND salary > :min_sal

Wolfgang Breitling
Oracle7, 8, 8i, 9i OCP DBA
Centrex Consulting Corporation
http://www.centrexcc.com

-- 
Please see the official ORACLE-L FAQ: http://www.orafaq.net
-- 
Author: Wolfgang Breitling
INET: breitliw_at_centrexcc.com

Fat City Network Services -- 858-538-5051 http://www.fatcity.com
San Diego, California -- Mailing list an! d web hosting services
---------------------------------------------------------------------
To REMOVE yourself from this mailing list, send an E-Mail message
to: ListGuru_at_fatcity.com (note EXACT spelling of 'ListGuru') and in
the message BODY, include a line containing: UNSUB ORACLE-L
(or the name of mailing list you want to be removed from). You may
also send the HELP command for other information (like subscribing).



  _____  

Do you Yahoo!?
Protect  <http://antispam.yahoo.com/whatsnewfree> your identity with Yahoo!
Mail AddressGuard




-- 
Please see the official ORACLE-L FAQ: http://www.orafaq.net
-- 
Author: Naveen, Nahata (IE10)
  INET: Naveen.Nahata_at_honeywell.com

Fat City Network Services    -- 858-538-5051 http://www.fatcity.com
San Diego, California        -- Mailing list and web hosting services
---------------------------------------------------------------------
To REMOVE yourself from this mailing list, send an E-Mail message
to: ListGuru_at_fatcity.com (note EXACT spelling of 'ListGuru') and in
the message BODY, include a line containing: UNSUB ORACLE-L
(or the name of mailing list you want to be removed from).  You may
also send the HELP command for other information (like subscribing).
Received on Tue Nov 04 2003 - 23:59:25 CST

Original text of this message

HOME | ASK QUESTION | ADD INFO | SEARCH | E-MAIL US