I\'m using Oracle, and I have a very large table. I need to check for the existence of any row meeting some simple criteria. What\'s the best way to go about this using simple
Using COUNT(*) is OK if you also use rownum=1:
declare
l_cnt integer;
begin
select count(*)
into l_cnt
from x
where x.col_a = value_a
and x.col_b = value_b
and rownum = 1;
end;
This will always return a row, so no need to handle any NO_DATA_FOUND exception. The value of l_cnt will be 0 (no rows) or 1 (at least 1 row exists).