Update failed. Found 2234 records.

Discussion of open issues, suggestions and bugs regarding IBDAC (InterBase Data Access Components) for Delphi, C++Builder, Lazarus (and FPC)
Post Reply
ralle1
Posts: 43
Joined: Thu 27 May 2010 15:01

Update failed. Found 2234 records.

Post by ralle1 » Thu 27 May 2010 15:11

Hello!

First, please excuse my bad english, i hope you will understand the following text:

I have got a Live Dataset, that meens
ReadOnly := false;

The primary Key of the selected Table is not in the Statement, f.e.:
SELECT BlobField FROM Table WHERE pkey=123

The blobfield will be edited with a DBMemo Component.
The Update will fail, because of primary key is missing.

This Error occurs: Update failed. Found 2234 records.

2234 is the record count of the Table. All Records will be edited!

How can i prevent such a error. It's ok, if the component will bring an error, but this reaction destroys the data of my customer.

The problem is, that this appication is an ex BDE program. With the BDE it was no problem to miss the primary key. Now I can't measure if there any other statements with this error. So I want to prevent this in my Database components.

Please help me.

Thanks a lot.

Dimon
Devart Team
Posts: 2910
Joined: Mon 05 Mar 2007 16:32

Post by Dimon » Fri 28 May 2010 11:06

To solve the problem you should use SQLUpdate property to specify the SQL statement that will be used when applying an update to a dataset, like this:

Code: Select all

  IBCQuery.SQLUpdate.Text := 'UPDATE Table SET BlobField = :BlobField WHERE pkey=123';

ralle1
Posts: 43
Joined: Thu 27 May 2010 15:01

Post by ralle1 » Fri 28 May 2010 13:00

Thank you for your answer.

The main problem is, that such code is in innumerable places in the code. It's an Application with more than 1200 Classes.

I always use a derivation of TIBCQuery ->

Code: Select all

TMyIBCQuery = class(TIBCQuery)
I am searching for a solution, that prevents the update in this cases.
There can be a program error, but the data of the customer may not be destroyed.

In the BDE TQuery there was a property UpdateMode which you can set to upWhereKeyOnly.

Is there any comparable in TIBCQuery?

Dimon
Devart Team
Posts: 2910
Joined: Mon 05 Mar 2007 16:32

Post by Dimon » Fri 28 May 2010 15:59

IBDAC doesn't support the UpdateMode property.
The point is that TIBCQuery for the updating records tries to execute the query which includes only one blob field entered in SQL statement. To avoid this problem, you should use SELECT query with key fields or set the SQLUpdate property, like this:

Code: Select all

SELECT pkey, BlobField FROM Table WHERE pkey=123

Post Reply