Oracle batch update inserting duplicate records
843854May 29 2002 — edited May 30 2002Problem: duplicate records being inserted during a batch update.
Here is a sample of my code:
// Start of code sample
int f1var = 0, f2var = 0, f3var = 0;
while (true) {
sql = "INSERT INTO Table1 (Field1, Field2, Field3) VALUES (" + f1var + ", " + f2var + ", " + f3var + ")";
stmt.addBatch(sql);
// other statements that change the value of the int vars and breaks out of the loop after 58 cycles
}
int [] updateCounts = stmt.executeBatch();
// End of code sample
After this code is run, the length of the updateCounts array is 58, and the value of each element in this array is 1 (as it should be). But 116 records are inserted in Table1, two identical records for each loop (usually, but not always, i.e., inconsistent problem).
Does anyone have any suggestions on what might be causing this problem?
TIA,
Logan