Thanks for the question, Jeyaram.
Asked: October 23, 2019 - 10:42 am UTC
Last updated: October 23, 2019 - 4:25 pm UTC
Version: 12.2.0.1.0
Viewed 1000+ times
You Asked
Hi Guys,
I have a schema with multiple Schema objects like Procedures,Functions,Triggers and Packages.
While testing via application if any DB error occurs we need to check the log to identify errors.
Is there any way to create a single trigger to track database event and if any error occurs in any object it should be inserted into a table.
Ignore if its a stupid question.
Thank You
and Chris said...
You're looking for an AFTER SERVERERROR ON DATABASE trigger:
create or replace trigger catch_errors
after servererror
on database
begin
dbms_output.put_line (
'An error happened!'
);
end catch_errors;
/
create table t (
c1 int
);
insert into t values ( sysdate );
SQL> insert into t values ( sysdate );
An error happened!
insert into t values ( sysdate )
*
ERROR at line 1:
ORA-00932: inconsistent datatypes: expected NUMBER got DATE
Catch the details you want in the trigger and write it to a table.
Is this answer out of date? If it is, please let us know via a Comment