Avoid raising standard exceptions
ZPA rule for PL/SQL and Oracle SQL · RaiseStandardException
Predefined exceptions such as NO_DATA_FOUND or TOO_MANY_ROWS tell that a specific operation failed. Raising one explicitly makes the code lie about what happened: a handler meant for a failed lookup catches a business condition, and it often means an exception is used as a jump to the handler instead of plain control flow.
This rule reports a RAISE of a predefined exception of STANDARD (NO_DATA_FOUND, TOO_MANY_ROWS, VALUE_ERROR, ZERO_DIVIDE, DUP_VAL_ON_INDEX, INVALID_NUMBER...). Use control flow, or a user-defined exception or RAISE_APPLICATION_ERROR that names the condition.
Examples
create function rack_is_full(p_rack in number) return boolean is
l_free number;
begin
select capacity - used into l_free from rack where id = p_rack;
if l_free = 0 then
raise too_many_rows; -- Noncompliant
end if;
return false;
exception
when too_many_rows then
return true;
end;
create function rack_is_full(p_rack in number) return boolean is
l_free number;
begin
select capacity - used into l_free from rack where id = p_rack;
return l_free = 0;
end;