Page 1 of 1

Batch insert trouble

Posted: Wed 21 Dec 2016 14:28
by plevrier
Hi,

I am using batch update functionality with a TUniQuery and Postgres.

In this case I have 2 identical tables and I wrote simple code to insert 2 records in both tables using an Array of Params.

For some reason all records are posted into the first table. How can I reset the TUniQuery component so that Batch operation functions normal for the second table ?
Really strange is that DB monitor shows me the query's I would expect (!)

You need table1 and table two with an Integer and character field to try this code below.

My config : Delphi XE5 ; UniDac 6.4.16 ; DBMonitor 3.0.4 ; Postgres 9.5

Code: Select all

  Q1.SQL.Text := 'insert into table1 (val1, val2) values (:PAR0, :PAR1)';
  Q1.Params[0].DataType := ftInteger;    
  Q1.Params[1].DataType := ftString;     
  //
  Q1.Params.ValueCount := 2;
  // 1st
  Q1.Params[0][0].asInteger  := 1;
  Q1.Params[1][0].asString   := 'test 1';
  // 2nd
  Q1.Params[0][1].asInteger  := 2;
  Q1.Params[1][1].asString   := 'test 2';

  Q1.Execute(2);

  /////////////////////

  Q1.SQL.Text := 'insert into table2 (val1, val2) values (:PAR0, :PAR1)';
  Q1.Params[0].DataType := ftInteger;    
  Q1.Params[1].DataType := ftString;     
  //
  Q1.Params.ValueCount := 2;
  // 1st
  Q1.Params[0][0].asInteger  := 1;
  Q1.Params[1][0].asString   := 'test 1';
  // 2nd
  Q1.Params[0][1].asInteger  := 2;
  Q1.Params[1][1].asString   := 'test 2';

  Q1.Execute(2);
Somebody have a clue / solution ?

Regards,
Pascal

Re: Batch insert trouble

Posted: Fri 23 Dec 2016 09:26
by azyk
Thank you for the information. We reproduced this error and will fix it.

Re: Batch insert trouble

Posted: Mon 06 Mar 2017 10:25
by azyk
We have fixed this problem. This fix will be included in the next UniDAC build