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
Exception handling would be the first thing I think of too, but if you don't want to burden yourself with handling all the different cases, I tend to use a select count(*) from
. The nice thing with count(*) is that it ALWAYS returns something (assuming your query is legal). In this case you could count to see if it returns 0 (no matches) or more (in which case you can do something.
You could get something like this:
declare
v_count number := 0;
begin
select count(*) into v_count from table where condition;
if v_count = 0 then
--do something
else
--do something else
end if;
end;