| Oracle FAQ | Your Portal to the Oracle Knowledge Grid | |
Home -> Community -> Usenet -> c.d.o.misc -> Re: Newbie PL/SQL inquiry regarding existence check.
Zernan Martinez wrote:
>
> I don't think so. The "rownum" column will be evaluated before the
> other conditions in the "where" clause.
>
> Zern
But that's OK. It's only going to be incremented if the other conditions are true.
SELECT COUNT(*) FROM table WHERE column=value AND ROWNUM=1;
will return 0 if there are no rows where column=value or 1 if there are one or more. Once it finds the first one with column=value, it will strop searching. There could be a problem if the table is very large and there are no rows that satisfy the condition. This can be alleviated by having an index that can be used to evaluate the WHERE clause.
Hope this helps
Ken Denny
kendenny_at_bnr.ca (work)
kdenny_at_interpath.com (home)
> On 7 Oct 1997 20:04:19 GMT, "Gerard H. Pille" <ghp_at_skynet.be> wrote:
>
> >You might try to add a "and rownum <= 1" to the where-clause.
> >--
> >Kind reGards,
> >
> >Gerard
> >(ghp_at_santens.be; ghp_at_skynet.be)
> >
[snip] Received on Wed Oct 08 1997 - 00:00:00 CDT
![]() |
![]() |