Batch insert trouble

Discussion of open issues, suggestions and bugs regarding UniDAC (Universal Data Access Components) for Delphi, C++Builder, Lazarus (and FPC)
Post Reply
plevrier
Posts: 4
Joined: Fri 16 Dec 2016 09:03

Batch insert trouble

Post by plevrier » Wed 21 Dec 2016 14:28

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

azyk
Devart Team
Posts: 1119
Joined: Fri 11 Apr 2014 11:47
Location: Alpha Centauri A

Re: Batch insert trouble

Post by azyk » Fri 23 Dec 2016 09:26

Thank you for the information. We reproduced this error and will fix it.

azyk
Devart Team
Posts: 1119
Joined: Fri 11 Apr 2014 11:47
Location: Alpha Centauri A

Re: Batch insert trouble

Post by azyk » Mon 06 Mar 2017 10:25

We have fixed this problem. This fix will be included in the next UniDAC build

Post Reply