I am insertin some values in Table2
from Table1
. There could be chances that there are Primary Key collision. I am using EXECUTE IMMEDIATE
to insert value from Table1
to Table2
.
The records could be in million and there is only 1 commit i.e.,
execute immediate 'insert into table 2 (select * from table 1)';
delete from table1;
commit;
EXCEPTION
WHEN DUP_VAL_ON_INDEX THEN
ROLLBACK;
--LOGGING
Is there a way that i can log the exact row which caused primary key collision in exception block ?
I know i can use "bulk" insert and "save exception" method but for some complex reasons,I am not allowed to change the script for this thing right now.
Any suggestions ?