Insert Batch Update

Discussion of open issues, suggestions and bugs regarding LiteDAC (SQLite Data Access Components) for Delphi, C++Builder, Lazarus (and FPC)
Post Reply
ProvalisResearch
Posts: 7
Joined: Tue 25 Jul 2017 13:53

Insert Batch Update

Post by ProvalisResearch » Tue 25 Jul 2017 16:57

Hello,

My scenario is batch inserting using the following method:

FBufferSize := 1000;

...
FLiteConnection.SQL.Params[0][FDBCount].AsLongWord := FCount;
FLiteConnection.SQL.Params[1][FDBCount].AsInteger := FHasher.GetHashValue(aExpression);
FLiteConnection.SQL.Params[2][FDBCount].AsLongWord := FTextRecordNumber;
...

Inc(FDBCount);

if (FDBCount = FBufferSize) then
begin
FLiteConnection.SQL.Execute(FDBCount);
FDBCount := 0;
end;

...

// End of process
if (FDBCount <> 0) then
begin
FLiteConnection.SQL.Execute(FDBCount);
FDBCount := 0;
end;

In the end of process, if the value of FDBCount=1, I get a ‘UNIQUE constraint failed’.

If I skip the SQL.Execute if FDBCount=1 and close everything, it does seem to save the record anyway.

If FDBCount>1, no issues. If I set the FBufferSize := 1, of course no problem.

I have a lot of records so simple inserts would take too much time.

I tried using a TLiteQuery connected to the connection, same problem.

Am I doing anything wrong? If not, is there a bug fix out?

I have the standard version (no source code).


Pierre

MaximG
Devart Team
Posts: 1822
Joined: Mon 06 Jul 2015 11:34

Re: Insert Batch Update

Post by MaximG » Thu 27 Jul 2017 08:09

Thank you for your information. Unfortunately, the information you provided is not enough to reproduce the problem. Please use the e-support form (https://www.devart.com - the menu "Support" \ "Request Support") to compile and send us a complete example of the way you fill the table. In addition, this example should include a DDL-script to create the table used in this example.

ProvalisResearch
Posts: 7
Joined: Tue 25 Jul 2017 13:53

Re: Insert Batch Update

Post by ProvalisResearch » Wed 23 Aug 2017 12:53

Sorry for the delay, I was on vacation.

As requested, I sent you a project that reproduces the issue.

Looking forward to your response.

Thank you for your time.

MaximG
Devart Team
Posts: 1822
Joined: Mon 06 Jul 2015 11:34

Re: Insert Batch Update

Post by MaximG » Mon 28 Aug 2017 14:37

Unfortunately, we did not get the composed project. Try to send it again using the e-support form(https://www.devart.com - the "Support"\"Request Support" menu)

ProvalisResearch
Posts: 7
Joined: Tue 25 Jul 2017 13:53

Re: Insert Batch Update

Post by ProvalisResearch » Tue 29 Aug 2017 10:55

I sent the project again. Please confirm you have received it.

Thank you.

MaximG
Devart Team
Posts: 1822
Joined: Mon 06 Jul 2015 11:34

Re: Insert Batch Update

Post by MaximG » Wed 30 Aug 2017 12:24

Thank you for the information. We reproduced the problem and fixed this bug. The fix will be included in the next LiteDAC build. As a workarround we can send you a night LiteDAC build with these fixes.
For this, provide your license number using the e-support form (https://www.devart.com - the "Support" \ "Request Support" menu) .

Post Reply