When inserting multiple times using a prepared statement, the number of inserted rows is limited to the minimum number in the batch. For example, if at some point the number of rows was 5, then subsequent executions will only insert a maximum of 5 rows, regardless of the actual number.
Batch 1
Actual number of rows: 10
Inserted number of rows: 10
Batch 2
Actual number of rows: 10
Inserted number of rows: 10
Batch 3
Actual number of rows: 5
Inserted number of rows: 5
Batch 4
Actual number of rows: 10
Inserted number of rows: 5 <-- must be 10
Batch 5
Actual number of rows: 10
Inserted number of rows: 5 <-- must be 10
When inserting multiple times using a prepared statement, the number of inserted rows is limited to the minimum number in the batch. For example, if at some point the number of rows was 5, then subsequent executions will only insert a maximum of 5 rows, regardless of the actual number.
Code example:
Output:
Results in DB:
The problem is also present when working with transactions using Tx.Stmt().