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: Getting the first matching record???

Re: Getting the first matching record???

From: Hugo Rojas H. <hurojas_at_sol.racsa.co.cr>
Date: 1997/04/13
Message-ID: <3350FB6C.6B64@sol.racsa.co.cr>#1/1

Chrysalis wrote:
>
> Michael Agbaglo wrote:
> >
> > SELECT COUNT(*), A, B
> > FROM ...
> > WHERE ...
> > GROUP BY A, B
> > HAVING COUNT(*) = 1
> >
> > Z. Martinez <zlm101_at_psu.edu> schrieb im Beitrag
> > <334bd241.9605767_at_news.cac.psu.edu>...
> > >
> > > I have a large table (about 4 million rows) that I need to search
> > > through. Although the query I'm using can result to multiple rows, I
> > > only need the first matching row. This query will be executed probably
> > > a hundred thousand times. So I really need to optimize it
> > >
> > > What is the most efficient way of getting the first matching record
> > > PL/SQL? and Pro*C?
> > >
> > > Thanks in advance.
> > >
> > > Please send your response to zlm101_at_psu.edu
> > >
> > >
> > >
>
> Nonsense!
> This does not achieve the desired result! It guarantees that if there
> is more than one matching row (count(*) > 1) no row will be returned at
> all!
>
> Chrysalis.

I think, why not use a cursor, just fetch the first record and close the cursor.

In addition, if you use the query in a client tool, use a stored procedure, which will return the record you need to your client.

-- 

    ____     _____       |
  /___ /|   /____/ \     | Hugo Rojas Hernández
 / ___|/   |  __ \ /|    | hurojas_at_sol.racsa.co.cr
| | |__    | |__) |/     | Costa Rica
| |/__ /|  |  __  /\     | 
 \____|/   |_|/ \_\/     |
Received on Sun Apr 13 1997 - 00:00:00 CDT

Original text of this message

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