Re: Quickest/Efficent Row Exist!
Date: 1996/07/31
Message-ID: <31febd77.5297096_at_dcsun4>#1/1
On Fri, 26 Jul 1996 03:54:10 GMT, shewring_at_wmcpet.dialix.oz.au (Marc Shewring) wrote:
>G'Day
>
>
>Does anyone know a quicker way of working out whether an item exists
>within the database other than doing...
>
>
>select count(*) from tech
>where r_code='TECH1234';
>
select count(*)
into :n
from DUAL
where exists ( select NULL
from tech where r_code = :bv )
would be one of the fastest ways to check for existence. The where exists will short circut when it finds the first match and DUAL is *very* small so scanning is immediate.
>
>Regards MArc
>------------------------------------------------------------------------------
>Marc Shewring
>Information Technology Officer "If you build it...
>Western Mining Corporation - Petroleum Division They will surf..."
>
>Marc.Shewring_at_wmc.com.au
>Marc.Shewring_at_p085.aone.net.au
>mcs_at_interlink.com.au
>------------------------------------------------------------------------------
>
Thomas Kyte
Oracle Government
tkyte_at_us.oracle.com
http://govt.us.oracle.com -- Check out our web site! Brand new, uses Oracle Web Server and Database
statements and opinions are mine and do not necessarily reflect the opinions of Oracle Corporation Received on Wed Jul 31 1996 - 00:00:00 CEST