Path: news.easynews.com!newsfeed1.easynews.com!easynews.com!easynews!newspump.sol.net!uwm.edu!news.cse.psu.edu!news.ems.psu.edu!newsfeed.stanford.edu!postnews1.google.com!not-for-mail
From: joel-garry@home.com (Joel Garry)
Newsgroups: comp.databases.oracle.server
Subject: Re: 1=1
Date: 10 Oct 2002 10:15:04 -0700
Organization: http://groups.google.com/
Lines: 29
Message-ID: <91884734.0210100915.3b64eb81@posting.google.com>
References: <91884734.0210091256.32c7fe4b@posting.google.com> <TQ1p9.1814$u87.135229595@newssvr21.news.prodigy.com>
NNTP-Posting-Host: 67.116.125.178
Content-Type: text/plain; charset=ISO-8859-1
Content-Transfer-Encoding: 8bit
X-Trace: posting.google.com 1034270104 4976 127.0.0.1 (10 Oct 2002 17:15:04 GMT)
X-Complaints-To: groups-abuse@google.com
NNTP-Posting-Date: 10 Oct 2002 17:15:04 GMT
Xref: newsfeed1.easynews.com comp.databases.oracle.server:163748
X-Received-Date: Thu, 10 Oct 2002 10:14:59 MST (news.easynews.com)

Karsten Farell <kfarrell@medimpact.com> wrote in message news:<TQ1p9.1814$u87.135229595@newssvr21.news.prodigy.com>...
> Joel Garry wrote:
> > Whilst examining some slow vendor-generated OCI code with Top Session,
> > I noticed some clauses like this:
> > 
> > SELECT A1.ROWID,
> > ...
> > WHERE ((A1.COMPANY_CODE=:1 AND A1.DIVISION=:5) AND 1=1)
> > 
> > What magic is the 1=1?
> 
> It's a common technique used in dynamic sql. So that you don't have to 
> code your WHERE clause for first line being 'WHERE' and subsequent lines 
> being 'AND' ... all you do is code your first line as 'WHERE 1=1' and 
> then you can tack on any additional dynamic where clauses as 'AND 
> condition'.

I was hoping that wouldn't be the answer.  But... it's the _last_
one...
[and I've seen others ending with AND 1=1) AND 1=1)]

I just have some vague memory from years ago that it had some sort
of useful effect in rule-based.

jg
--
@home is bogus.
Why is Kurt Cobain singing about French bread?
"Paaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaain."
