Oracle - abort within a "before insert" trigger without throwing an exception I know that this is an awful thing to do for many reasons, but I am in Get Things Done mode and we have a piece of software, which we can't modify, that writes records to a table. Some of these records, for business reasons, we don't want in this table. I was thinking I could write a trigger that "aborts" any of these rows without throwing an error (so that the application doesn't fail in the front end, we want it to think it did its thing). I am intimately familiar with this application and know it won't cause any ugly side effects, we just can't modify it to behave the way we need it to.

So, is this possible, and if not, what would be another way to go about it? I thought about having some sort of Job that routinely cleans the table for records that we don't want, but I would rather for these records to never be there to begin with so there's no degree of "dirtiness" at any one time in the table.
The only way for a trigger on a table to prevent an INSERT operation from completing is to throw an error.

It is, as you have stated, a huge hack, but you could


Rename the table
Create a view that has the same name as the original table
Create an instead of trigger on that view that only does an INSERT on the table if you want the row to be persisted.  Otherwise, the trigger would do nothing.


That should work so long as the application isn't doing a MERGE into the table.  Of course, it's a hack upon a hack so it's definitely not going to win any awards for clean code.