View Single Post

   
  #2 (permalink)  
Old 04-15-2008, 11:37 PM
Oliver Jowett
 
Posts: n/a
Default Re: Strange behavoir of batches

Angelo Neuschitzer wrote:

>> PreparedStatemet pStmt = con.prepareStatement("INSERT INTO table_a
>> VALUES (...)");
>> for(0 to 93)
>> {
>> [fill values into pStmt]
>> if(not last row)
>> {
>> pStmt.addBatch();
>> }
>> }
>> pStmt.executeBatch();
>> pStmt.clearBatch();


AFAIK, this "not last row" logic seems wrong. Calling executeBatch()
only executes those queries that have been added to the batch via
addBatch(), so the loop will lose the last INSERT.

-O

---------------------------(end of broadcast)---------------------------
TIP 3: Have you checked our extensive FAQ?

http://www.postgresql.org/docs/faq

Reply With Quote