Boa tarde, Percio!
We need to integrate some real data to a datawarehouse staging table. We're going to truncate first the destination table before any insert.
Our DBA requested us to execute a commit every 1,000 records to not increase resources consumption on the server.
In case of any error... we're going to stop the interface execution and drop the destination table again, so the B.I system won't load incomplete data and we can check what happened and/or manually execute the interface again.
We thought about doing it by using U.M and triggers with the "Retry on failure", but I'm not sure if this approach would be the best in the current scenario.
Abs!
------------------------------
Renan Kaic Lopes
------------------------------
Original Message:
Sent: Fri June 12, 2026 10:17 AM
From: Percio Castro
Subject: Using Batch insert and update service - how to set a "Commit after x rows" rule?
Bom dia, Renan -
Out of curiosity: why do you want to do this?
Do you have a plan for what to do you if one of your groups of transactions fail? For example, let's say you have 5,000 records to be inserted. The first group of 1,000 records get committed successfully, but the second group fails. Will you move on to the next group? Will you abort? And what happens with that first group that was successfully inserted? Doing commits mid-batch may complicate your exception scenarios a bit.
And the answer to your question is "yes": the startTransaction and commitTransaction go hand-in-hand. If you're going to do commits within the loop, then startTransaction will also need to be in the loop (and perhaps rollbackTransaction as well depending on how you decide to handle exceptions).
Abs!
------------------------------
Percio
https://nibl.tech
------------------------------
Original Message:
Sent: Fri June 12, 2026 08:03 AM
From: Renan Kaic Lopes
Subject: Using Batch insert and update service - how to set a "Commit after x rows" rule?
Dear Dave,
Thank you very much for your answer.
After commiting the transaction, should we call the startTransaction again?
We'll soon implement the way you suggested and let you know the results.
------------------------------
Renan Kaic Lopes
------------------------------
Original Message:
Sent: Thu June 11, 2026 05:23 PM
From: Dave Laycock
Subject: Using Batch insert and update service - how to set a "Commit after x rows" rule?
I have seen using a loop and the $iteration variable. Create a Java service to wrap the integer modulo operator (unfortunately, there is no pub.math mod service)
Assuming your data is in list, very rough pseudocode
loop over list of listSize { add current list item to batchInsertlist if ($iteration % 1000 == 0 || $iteration == listSize) { // current iteration is evenly divisible by 1000 or the final iteration batchInsert batchInsertlist commit transaction }}
Another idea would be to partition your list into smaller lists using pub.document:groupDocuments loop over the returned documentGroups list. But that could be challenging to get groups of predictable fixed sizes
------------------------------
Dave Laycock
------------------------------