Re: Why use it : SELECT 1 FROM DUAL

  • From: Eriovaldo Andrietta <ecandrietta@xxxxxxxxx>
  • To: tim@xxxxxxxxx
  • Date: Thu, 2 Aug 2012 15:15:38 -0300

Thanks Tim and Robert.
I got the message.
And answers make sense.

Regards
Eriovaldo

On Thu, Aug 2, 2012 at 3:00 PM, Tim Gorman <tim@xxxxxxxxx> wrote:

> Lots of developers, when generating SQL statements dynamically, use the
> predicate "1 = 1" or something similar so as not to leave an "AND"
> keyword dangling without a predicate.  So, for example they'll have an
> IF-THEN-ELSE condition in the code building the SQL statement that
> generates an actual predicate in the THEN condition and hard-codes the
> no-op of "1 = 1" in the ELSE condition.
>
> It's an artifact of a slightly clumsy programming method, rather than
> any form of optimization.
>
>
> On 8/2/2012 11:52 AM, Eriovaldo Andrietta wrote:
> > Hello friends,
> > I am analyzing some sql statments and found out in all queries the
> > developer added the following where clause plus others...
> >
> >     and exists (select 1 from dual)
> >
> >
> > All queries has this code.
> >
> > Is there any good reason to put it in the sql statment ?
> > Does it improve performance ?
> >
> > This is the first time I see it in SQL ?
> >
> > Regards
> > Eriovaldo
> --
> //www.freelists.org/webpage/oracle-l
>
>
>


--
//www.freelists.org/webpage/oracle-l


Other related posts: