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: where 1=1 ?

Re: where 1=1 ?

From: Nuno Souto <nsouto_at_nsw.bigpond.net.au.nospam>
Date: 2000/03/17
Message-ID: <38d217bc.9152877@news-server>#1/1

On Thu, 16 Mar 2000 15:47:04 +0100, Julio <julio.negueruela_at_si.unirioja.es> wrote:

>to) optimize some queries they use and I've seen a lot of occurrencies of that
>strange clause show above. I.e.:
>
>select empno from emp
>where 1=1 and empdpt='COMPUTER';
>Does anybody wich is the utility of introducing such comparison?

Pure convenience in editing.

If one tends to write (lines are relevant):

SELECT
  column_name[,...]
FROM table_a[,...]
WHERE 1=1
AND <predicate>

.
.
.

it now becomes extremely easy to use a text editor to cut and paste entire lines into the predicates without having to worry if the WHERE precidate matches or duplicates with the rest: it's always 1=1 and true, so what really drives the predicates is the AND lines below.

But when you see the code in Explain Plan or tkprof or V$SQLAREA, the line-by-line arrangement becomes all messed up and it looks weird. If you peek at original source, in all likelyhood it will look arranged by line.

Text editing convenience. That's all.

Cheers
Nuno Souto
nsouto_at_nsw.bigpond.net.au.nospam
http://www.users.bigpond.net.au/the_Den/index.html Received on Fri Mar 17 2000 - 00:00:00 CST

Original text of this message

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