Skip to Main Content



Connor and Chris don't just spend all day on AskTOM. You can also catch regular content via Connor's blog and Chris's blog. Or if video is more your thing, check out Connor's latest video and Chris's latest video from their Youtube channels. And of course, keep up to date with AskTOM via the official twitter account.

Question and Answer

Chris Saxon

Thanks for the question, Jeyaram.

Asked: October 23, 2019 - 10:42 am UTC

Answered by: Chris Saxon - Last updated: October 23, 2019 - 4:25 pm UTC

Category: Database Administration - Version:

Viewed 100+ times

Whilst you are here, check out some content from the AskTom team: On Connection Pools, Cursor Differentiation, and Optimal Ordering

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 we said...

You're looking for an AFTER SERVERERROR ON DATABASE trigger:

create or replace trigger catch_errors
after servererror
on database
  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.

More to Explore


Check out more PL/SQL tutorials on our LiveSQL tool.