In a PSQL-exception handler custom logic can be added to more appropriately handle an exception, such as:
declare
l_x pls_integer;
begin
l_x := 1/0;
exception
when others
then
null; -- Ignore error.
end;
The divide by zero-error will then be suppressed completely. However, in many scenarios system logging is required and the use of Invantive Trace may be too resource consuming.
Starting release 20.2.8 the exception can be logged to Invantive Cloud for consultation through the System Messages form using the stored procedure dbms_trace.register_exception
. Register_exception
uses the current exception and has no further parameters. It is only valid within an exception handler.
The resulting code with central logging on Invantive Cloud is:
declare
l_x pls_integer;
begin
l_x := 1/0;
exception
when others
then
null; -- Ignore error. Actually null is not needed since there is another statement in this block.
dbms_trace.register_exception();
end;