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: Checking if more than 0 rows exist.

Re: Checking if more than 0 rows exist.

From: DA Morgan <damorgan_at_x.washington.edu>
Date: Tue, 10 May 2005 08:07:57 -0700
Message-ID: <1115737425.855087@yasure>


Jeremy wrote:

> In article <d5og57$je0$1_at_news3.zwoll1.ov.home.nl>, Frank van Bortel
> says...
>

>>>Select count(*) from combo_table where all fields match would count them all 
>>>but all I really need to know is if any exist (>0 rows).
>>>
>>
>>Right question: define a cursor with all 5 columns concerned.
>>Open the cursor - (attempt to) fetch any record.
>>If found, you're OK - close cursor, 1 read done.
>>If not found, you're OK - close cursor, 1 read done.
>>
>>

>
>
>
> Do you think this is a better approach than using EXISTS as suggested
> (and proved to be faster) by Phil?

One thing's for sure. A cursor is almost never the correct solution to anything in Oracle unless using a version more than 5 years old.

-- 
Daniel A. Morgan
University of Washington
damorgan_at_x.washington.edu
(replace 'x' with 'u' to respond)
Received on Tue May 10 2005 - 10:07:57 CDT

Original text of this message

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