Oracle FAQ | Your Portal to the Oracle Knowledge Grid |
Home -> Community -> Usenet -> c.d.o.server -> Re: 1=1
Karsten Farell <kfarrell_at_medimpact.com> wrote in message news:<TQ1p9.1814$u87.135229595_at_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."Received on Thu Oct 10 2002 - 12:15:04 CDT