Page 1 of 1

Insert Batch Update

Posted: Tue 25 Jul 2017 16:57
by ProvalisResearch
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

Re: Insert Batch Update

Posted: Thu 27 Jul 2017 08:09
by MaximG
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.

Re: Insert Batch Update

Posted: Wed 23 Aug 2017 12:53
by ProvalisResearch
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.

Re: Insert Batch Update

Posted: Mon 28 Aug 2017 14:37
by MaximG
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)

Re: Insert Batch Update

Posted: Tue 29 Aug 2017 10:55
by ProvalisResearch
I sent the project again. Please confirm you have received it.

Thank you.

Re: Insert Batch Update

Posted: Wed 30 Aug 2017 12:24
by MaximG
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) .