I sometime used this kind of aproach when I dinamically build the WHERE
expression.
Something like this:

where_condition := ' WHERE 1 = 1 '
LOOP
   where_condition := ' AND ' || new_condition
END LOOP
The point is if there are any condition to add the first condition is always
true so it won't affect the final where_condition. The same is when there
aren't any condition to add. 
And in some cases there are really no conditions to add, thus your final
query will have only a condition like ' WHERE 1 = 1 '. 

If you need to connect all the intermediate condition by OR operator
probably you will use the 
WHERE 1 = 0.

I hope I'll make my point clear enough and of course is any related to your
case. Maybe if you show us the entire query, someone can tell you more about
it.

Regards 
Iulian Ilies



-----Original Message-----
Sent: Friday, October 26, 2001 2:20 AM
To: Multiple recipients of list ORACLE-L


**********************************************************************
This email has been tested for viruses by F-Secure Antivirus
administered by IT Network Department.
**********************************************************************

I was monitoring a load test of my company's new
application when I came across something interesting. 
One of the more monstrous queries had the following as
part of its WHERE clause: 'AND 1 = 1'

Has anyone seen this used before?  What is it supposed
to achieve?  

__________________________________________________
Do You Yahoo!?
Make a great connection at Yahoo! Personals.
http://personals.yahoo.com
-- 
Please see the official ORACLE-L FAQ: http://www.orafaq.com
-- 
Author: Ed Bittel
  INET: [EMAIL PROTECTED]

Fat City Network Services    -- (858) 538-5051  FAX: (858) 538-5051
San Diego, California        -- Public Internet access / Mailing Lists
--------------------------------------------------------------------
To REMOVE yourself from this mailing list, send an E-Mail message
to: [EMAIL PROTECTED] (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).


******************************************************************************
The information contained in this communication is confidential and 
may be legally privileged. It is intended solely for the use of the 
individual or entity to whom it is addressed and others authorised to 
receive it. If you are not the intended recipient you are hereby 
notified that any disclosure, copying, distribution or taking action in 
reliance of the contents of this information is strictly prohibited and 
may be unlawful. Mobil Rom is neither liable for the proper, complete 
transmission of the information contained in this communication nor 
any delay in its receipt.
******************************************************************************
-- 
Please see the official ORACLE-L FAQ: http://www.orafaq.com
-- 
Author: 
  INET: [EMAIL PROTECTED]

Fat City Network Services    -- (858) 538-5051  FAX: (858) 538-5051
San Diego, California        -- Public Internet access / Mailing Lists
--------------------------------------------------------------------
To REMOVE yourself from this mailing list, send an E-Mail message
to: [EMAIL PROTECTED] (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).

Reply via email to