Before a select SOMETHING into v_something
, I would like to know if my query returns a row.
Here are a good methods, but it cost two select
if the row exists :
select count(1) into isRowExists from PERSON where CONDITION='Something';
if (isRowExists > 0) then
select NAME into v_name from PERSON where CONDITION='Something';
else
raise name_not_found;
end if;
select count(1) into isRowExists from CAR where CONDITION='Something';
if (isRowExists > 0) then
select MODEL into v_model from CAR where CONDITION='Something';
else
raise model_not_found;
end if;
Or something like that :
select NAME into v_name from PERSON where CONDITION='Something';
select MODEL into v_model from CAR where CONDITION='Something';
exception
when no_data_found then
--do_something
But with this method, I don't know if the problem came from PERSON
or CAR
...
Is there any other solution ? Like sending a parameter to an exception
?