I have script files with thousands of sql INSERT INTO lines. Some of these lines will insert data that’s already in the database, so I want to catch these errors and just bypass it. Is there a way to catch errors thrown by a trigger and ignoring it?
ERROR at line 1:
ORA-20053: Username must be unique
ORA-06512: at "MY_TRIGGER", line 18
ORA-04088: error during execution of trigger 'MY_TRIGGER'
ORA-06512: at line 3
I could do this with unique constraints by catching a DUP_VAL_ON_INDEX and then doing NULL, but this does not work for the above trigger error.
You can define your own exception and use that just like you would use one of the default exception handlers like
dup_val_on_index.In general, though, it would make more sense to modify your scripts so that they only try to insert rows that do not already exist rather than letting the trigger try to flag them and then ignoring the error.