Oracle FAQ | Your Portal to the Oracle Knowledge Grid |
Home -> Community -> Usenet -> c.d.o.server -> Re: 1=1
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