I am using local_transaction in my connection and i want to perform batch insert
also i am using start,commit,rollback transaction in the service.
Now the scenario is that while insertion if error occurs it need to be added to log file and other insertions need to be taken place in database.
Let us assume 10 records the 6th record has error so the first five and from seventh till tenth i need to be in database so only sixth is not inserted so please let me know how to do it or other ways to achieve it.
The meaning of batch insert statement is to group a couple of related transactions into a single batch, commit if all statements are valid and roll back if any of the statement get errored. I guess,if your all statements in the batch performs a single transaction then please roll back batch insert and if all went well then commit the whole transaction. If you think they are independent then run those independently as you wish …
First of all the whole batch insert itself is a single transaction. If you want to trace individual transactions, create separate inserts accordingly. To handle errors, create a wrapper which has try catch block. In the catch block dont throw error, instead exit with success(Make sure to track those failed records by writing to file or something).