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: Q: pl/sql checking the existence of a record ?

Re: Q: pl/sql checking the existence of a record ?

From: <markp7832_at_my-deja.com>
Date: Mon, 17 Jan 2000 22:35:57 GMT
Message-ID: <8605gc$vu0$1@nnrp1.deja.com>


In article <85vg4m$f6v$1_at_nnrp1.deja.com>,   tedchyn_at_yahoo.com wrote:
> Sir, are there alternatives of checking the existence of a record
beside
> checking row count or sqlcode ?
> thanks in advance
> Ted Chyn
>

Not really as you have to query a record to see if it exists. Sometimes an exists sub-query can be used to do this:

select *
from some_table
where exists ( select X from some_table_or_other where ..... )

In pl/sql you can use a begin/end block with an exception clause and the no_data_found predefined exception to set a variable or ignore such a condition.

begin
select col1
into v_col1
from some_table
where col2 = 'A';
exception
  when no_data_found then null;
  when too_many_rows then v_col1 := 'B'; end;

I hope this helps.
--
Mark D. Powell -- The only advice that counts is the advice that  you follow so follow your own advice --

Sent via Deja.com http://www.deja.com/
Before you buy. Received on Mon Jan 17 2000 - 16:35:57 CST

Original text of this message

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