thanks, you sparked my memory, I KNEW I'd seen it somewhere :)
we had built a system where the users submitted the information they
wanted to select on through a form and we dynamically built the sql
statement. Since the program to build the statement always included
WHERE, by hard-coding WHERE 1=1 we were able to add the remainder of
the where clause as "AND ......". If there was nothing in the form, the
query still worked.
- G.Plivna_at_itsystems.lv wrote:
>
> Maybe You could find useful such approach:
>
> where_clause = '';
> comma = ' WHERE ';
> LOOP
> where_clause = comma || new_condition;
> comma = ' AND ';
> END LOOP;
>
> So in this case You don't need always WHERE in your select especially
> such
> interesting construction like 1=1
>
> BUT as always IT DEPENDS...
>
> Gints Plivna
> IT Sistēmas, Merķeļa 13, LV1050 Rīga
> http://www.itsystems.lv/gints/
>
>
>
>
>
> Iulian.ILIES_at_mob
>
> il-rom.com To: Multiple
> recipients of list ORACLE-L <ORACLE-L_at_fatcity.com>
> Sent by: cc:
>
> root_at_fatcity.com Subject: RE: Where 1 =
> 1
>
>
>
>
> 2001.10.26 09:55
>
> Please respond
>
> to ORACLE-L
>
>
>
>
>
>
>
>
>
> 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: bitlist_at_yahoo.com
>
> 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: 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).
>
>
>
>
> 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: Iulian.ILIES_at_mobil-rom.com
>
> 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: 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).
>
>
>
>
> --
> Please see the official ORACLE-L FAQ: http://www.orafaq.com
> --
> Author:
> INET: G.Plivna_at_itsystems.lv
>
> 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: 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!?
Make a great connection at Yahoo! Personals.
http://personals.yahoo.com
--
Please see the official ORACLE-L FAQ: http://www.orafaq.com
--
Author: Rachel Carmichael
INET: wisernet100_at_yahoo.com
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: 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 Fri Oct 26 2001 - 07:30:45 CDT