How can I handle the exception in a function call? It has a separate function returning 1 or 0 depending on the argument used.
If the function is_valid_eventTypesGeographicAddress throws me 0 I want to throw an exception.
I have no idea how to do this in this syntax.
select is_valid_eventTypesGeographicAddress (in_type) from dual ,
exception WHEN 0 then return ('Invalid geographic address type');
Code does not compile.
You can use PL/SQL and its RAISE_APPLICATION_ERROR procedure to throw an exception. Here's an example:
declare
myResult number;
begin
myResult := is_valid_eventTypesGeographicAddress (in_type);
if myResult = 0 then
raise_application_error(-20000, 'Invalid geographic address type');
end if;
end;
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With