How can I RAISE_APPLICATION_ERROR and do an INSERT in the same trigger?
-
31-12-2020 - |
Question
From what I see, having the RAISE_APPLICATION_ERROR
cancels the other operations that I would have in the trigger. I tried writing first the INSERT
and then the RAISE_APPLICATION_ERROR
hoping that they get executed in the order in which they are read but it doesn't work like this...The error is thrown and the INSERT
is canceled. How could I make both of the operations get executed (from the same trigger) ?
I also tried creating two triggers .. one of them doing the RAISE_APPLICATION_ERROR
part and the other doing the INSERT
and establishing the order using FOLLOWS
and PRECEDES
but it didn't work.
The trigger should block the DROP
DDL (that's what for I used the RAISE_APPLICATION_ERROR
) and it also should do an insert in a LOG
type table (that's what for I used the INSERT
).
Solution
Log type operations are usually done via AUTONOMOUS_TRANSACTION
procedures.
Don't have a logging package, get one from GitHub.