Oracle FAQ | Your Portal to the Oracle Knowledge Grid |
Home -> Community -> Usenet -> c.d.o.server -> Re: Q: pl/sql checking the existence of a record ?
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