I\'m writing a procedure, and i need to check whether my select query returned an empty record or not. (In this example whether there is no x,y shelf)
How can i do t
catch first not wanted condition and use count(1) because count(*) actually trying to count something and add rownum=1, you need only one first not matching condition. i use this statement.
declare
v_check number;
begin
select count(1) into v_check
from table
where condition(something not wanted) AND rownum=1;
if v_check = 0 then
--do something else
elsif v_check = 1 --dont want theat
rise some error or more..
end if;
end;
For you just
select count(1) into v_check from dual where exists (select count(1)
from table
where condition AND rownum=1);
if v_check = 0 then --nothing found
something...
elsif v_check = 1 --found something
something...
end if;
end;