Oracle FAQ Your Portal to the Oracle Knowledge Grid
HOME | ASK QUESTION | ADD INFO | SEARCH | E-MAIL US
 

Home -> Community -> Usenet -> c.d.o.misc -> Re: Q: Determining if a record exists

Re: Q: Determining if a record exists

From: <Christer.XK.Andersson_at_trab.se>
Date: 1997/03/20
Message-ID: <333140A5.1701@trab.se>#1/1

Count is the most efficient way and if you want to know if there are records and dont care how many, use the following:

select count (*) from <table_name>
where <exist_expression> and
rownum <= 1

This select statement returns 0 if there are no records and 1 if there are 1 or more records but only counts the first found of the existing records, for optimization.

If you dont use count Oracle will raise a no_data_found exception if the record does not exist. Count is the only way to avoid the no_data_found exception.

/br Christer Andersson!

Jim Poland wrote:
>
> What is the most efficient way to determine if a record exists if you're
> making the SQL call through ODBC? I've always assumed it was by doing a
> count but I'd like to know for sure.
>
> Thanks,
> Jim
Received on Thu Mar 20 1997 - 00:00:00 CST

Original text of this message

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