UniDAC and Batch Options - when SQL UPDATE fails to UPDATE

Discussion of open issues, suggestions and bugs regarding UniDAC (Universal Data Access Components) for Delphi, C++Builder, Lazarus (and FPC)
Post Reply
tkoscielski
Posts: 5
Joined: Mon 10 Jul 2017 21:49

UniDAC and Batch Options - when SQL UPDATE fails to UPDATE

Post by tkoscielski » Tue 21 Jun 2022 19:33

When using BATCH updates in UniDAC, the RowsAffected does reflect the number of rows UPDATED. However, I have the following scenario where there is an attempted UPDATE that fails because it could not find a corresponding table record based on the WHERE clause.

Code: Select all

SAMPLE TABLE FIELDS
=============
  AIncrementKey
  AStringField(10)
  AIntegerField

Code: Select all

SAMPLE DATA
=================
1    happy    10
2    sad      11
I build my UPDATE statement like this:

UPDATE SAMPLE Set AStringField=:AStringField WHERE AIncrementKey=:AIncrementKey

I then can use the PARAMS to populate the UPDATE statement, i.e.

Code: Select all

TUniQuery.Params[0][0].AsString := 'mad';
TUniQuery.Params[1][0].AsInteger := 2;

// Note that this record does not exist in the database table SAMPLE
TUniQuery.Params[0][1].AsString := 'frumpy';
TUniQuery.Params[1][1].AsInteger := 3;
When I run TUniQuery.Execute(2), I get back TUniQuery.RowsAffected := 1 telling me one row is updated. However, I'd like to know the error on the second update because it tried to update a record that did not exist.

Is there anyway to get information about which records in the PARAMS array failed to UPDATE?

Thanks.

pavelpd
Devart Team
Posts: 66
Joined: Thu 06 Jan 2022 14:16

Re: UniDAC and Batch Options - when SQL UPDATE fails to UPDATE

Post by pavelpd » Thu 30 Jun 2022 14:32

Hi,

Thanks for your request!

In the example you provided, there are no errors regarding the update of the second record since the data is updated according to the specified SQL query "UPDATE" and its "WHERE" statement.

There is no functionality in UniDAC that notifies about the lack of data to update during batch operations.

Feel free to reply if you have any questions or need additional information.

Post Reply