You can use the Oracle error logging function to do this:
First you need to create a table that will later contain ignored rows:
EXECUTE DBMS_ERRLOG.CREATE_ERROR_LOG('YOUR_TABLE', 'YOUR_TABLE_ERROR_LOG');
This creates a table named YOUR_TABLE_ERROR_LOG
for a table named YOUR_TABLE
(obviously, you only need to do this once).
When you run your UPDATE, you need to add the LOG ERRORS
:
UPDATE your_table SET ... WHERE ... LOG ERRORS INTO YOUR_TABLE_ERROR_LOG ('UPDATE running at '||to_char(sysdate, 'yyyy-MM-dd HH24:MI:SS')) REJECT LIMIT UNLIMITED;
The specified string is an arbitrary value that helps identify the action that caused the error.
After the update, you can query the YOUR_TABLE_ERROR_LOG table to find out what errors occurred and why. If you are not interested in errors, just trim the error log table after that.
See the manual for more details:
http://download.oracle.com/docs/cd/E11882_01/server.112/e17118/statements_10008.htm#BCEFBFCD
Change 2014-10-27
Since Oracle 11.2, there is a new tooltip called CHANGE_DUPKEY_ERROR_INDEX
that can be used for this purpose. I have never tried this though.
Details in the manual: http://docs.oracle.com/cd/E11882_01/server.112/e41084/sql_elements006.htm#CHDIFFJE
For INSERT
operations, there is a similar prompt named IGNORE_ROW_ON_DUPKEY_INDEX
:
http://docs.oracle.com/cd/E11882_01/server.112/e41084/sql_elements006.htm#CHDEGDDG
Some examples:
source share