Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Ignoring exception in oracle trigger

I have a table with some denormalized precalculated columns that are maintained by a trigger. The data sometimes is corrupted and the process fails but in these cases I need just ignore the exceptions and continue because it is not important to catch the error.

How can I write the exception clause to just go on without raising any error when an exception ocurrs?

I've tried just leaving the clause empty:

...
EXCEPTION
    WHEN OTHERS THEN


end test_trigger;

but it does not compile.

What am I missing? there is some "pass" clause that I should be including?

like image 814
Sam Avatar asked Aug 18 '09 20:08

Sam


People also ask

How do you handle exceptions in trigger?

If Trigger B throws an exception, the current connection is rolled back to the point before the statement in Trigger A that caused Trigger B to fire. Trigger A is then free to catch the exception thrown by Trigger B and continue with its work.

What happens if a trigger fails in Oracle?

Your insert will either entirely succeed (insert into t1 and into t2 succeed) or neither will - both will "fail" because the statement itself failed. So, after your insert, if the trigger failed - the database will look like your insert never ever happened.

Can we write exception in trigger in Oracle?

Yes. very easy solution is to use ON-ERROR trigger at any level of forms.

Can we use exception in trigger?

A trigger exception (also known as a "blocking trigger") is a kind of trigger that can be used to block another trigger's ability to fire under certain conditions. For example, if a tag has a trigger to fire on all pages and a trigger exception that is set to "Page URL equals thankyou.


1 Answers

...
EXCEPTION
    WHEN OTHERS THEN
        NULL;

end test_trigger;
like image 52
cagcowboy Avatar answered Sep 28 '22 08:09

cagcowboy