Hi Eugenio,
Is UPSERT acceptable to your scenario? If yes, you can replace INSERT with UPSERT which will either insert or update a record.
If not, I guess you would have to batch your records and commit after certain number of inserts, for example commit after every 10 inserts. If there is an exception only last batch (10 records ) is/are not committed.
Regards
Raj