I'd like to run a function that will select a ref into an attribute from an object table, and if the table returns null then the attribute is set to null. To achieve this I tried the code.
select ref(t) into self_ref from my_table where objectID = self.objectID;
But this fails anytime that the where fails to find a match. In place I have the following
select count(*)
into l_result
from my_table
where companyID = self.companyID;
if l_result > 0 then
select ref(t)
into self_ref
from my_table t
where objectID = self.objectID;
else
self_ref := null;
end if;
But I'd like if there was a better solution that didn't involve so much redundancy.
Any suggestions?