See Block structure:
<< label >> (optional) DECLARE -- Declarative part (optional) -- Declarations of local types, variables, & subprograms BEGIN -- Executable part (required) -- Statements (which can use items declared in declarative part) [EXCEPTION -- Exception-handling part (optional) -- Exception handlers for exceptions (errors) raised in executable part] END;
You need a BEGIN/END
for each EXCEPTION
:
if :payee_id is not null then
begin
<Select statement which place results into placeholders>
exception
when NO_DATA_FOUND then
return null;
end;
<code>
else
<else code>
end if;
Also note that the use of WHEN OTHERS
not followed by a RAISE
is a bad code smell. You don't want to ignore ALL errors, so be specific. Usually you only want to catch a NO_DATA_FOUND
.