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

Home -> Community -> Usenet -> c.d.o.server -> Re: 1=1

Re: 1=1

From: Karsten Farell <kfarrell_at_medimpact.com>
Date: Wed, 09 Oct 2002 22:12:03 GMT
Message-ID: <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'. Received on Wed Oct 09 2002 - 17:12:03 CDT

Original text of this message

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