Watch, Follow, &
Connect with Us

For forums, blogs and more please visit our
Developer Tools Community.


Welcome, Guest
Guest Settings
Help

Thread: Error [FireDAC] [DApt] -400: what does it mean?


This question is not answered. Helpful answers available: 2. Correct answers available: 1.


Permlink Replies: 8 - Last Post: Feb 14, 2018 6:05 AM Last Post By: takieddine aoua... Threads: [ Previous | Next ]
Trevor Cooper

Posts: 45
Registered: 10/7/10
Error [FireDAC] [DApt] -400: what does it mean?  
Click to report abuse...   Click to reply to this thread Reply
  Posted: Apr 2, 2015 8:25 AM
Hi,

I'm running a loop to update the value in a field of each record in a table of 20,000 records in an SQLite database. The entire process is embedded in an explicit transaction. I'm using FireDAC in XE5.

The calculated values come from a specialist component so the operation cannot be carried out as an update SQL.

The loop runs for several thousand records and then fails with an exception that reports '[FireDAC] [DApt] -400. Update command updated [0] instead of [1] record. Possible reasons: update table does not have PK or row identifier, record has been changed/deleted by another user'.

None of these possible reasons is helpful. The table has a primary key, and no other user or process has access to the table while this loop runs. What else can the problem be? There doesn't seem to be anything on this error in the DocWiki. Or is there?

Grateful for any advice.

Trevor Cooper
Dmitry Arefiev

Posts: 1,406
Registered: 12/7/03
Re: Error [FireDAC] [DApt] -400: what does it mean?  
Click to report abuse...   Click to reply to this thread Reply
  Posted: Apr 4, 2015 4:51 AM   in response to: Trevor Cooper in response to: Trevor Cooper
More reasons for this error:
* a float numeric data type field is used in WHERE clause. And a rounding issue happens.
* a CHAR data type field is used in WHERE clause. And FormatOptions.StrsTrim is True. So, a field is not padded by the spaces and matching fails.
* a string data type field has empty value and FormatOptions.StrsEmpty2Null is True. So, matching fails.
* similar to first option, but with date / time field.

--
With best regards,
Dmitry Arefiev / FireDAC Architect
Trevor Cooper

Posts: 45
Registered: 10/7/10
Re: Error [FireDAC] [DApt] -400: what does it mean?  
Click to report abuse...   Click to reply to this thread Reply
  Posted: Apr 7, 2015 7:37 AM   in response to: Dmitry Arefiev in response to: Dmitry Arefiev
Hi Dmitry,

Thanks for your advice. Unfortunately, the problem remains unresolved. As I am updating a table record by record, there is no WHERE clause involved. For each record, I'm posting two values, a floating point number and a string. Neither of these is ever blank or null, and StrsEmpty2Null is false.

The process fails at one record if I use an explicit transaction, and at another if I don't, so it seems as though the exception is raised regardless of the actual data being posted.

Do you have any ideas for other possible causes?

Regards

Trevor Cooper
Dmitry Arefiev

Posts: 1,406
Registered: 12/7/03
Re: Error [FireDAC] [DApt] -400: what does it mean?  
Click to report abuse...   Click to reply to this thread Reply
  Posted: Apr 7, 2015 7:41 AM   in response to: Trevor Cooper in response to: Trevor Cooper
If error is a transaction dependent, then it more looks like an application logic error.
I will suggest to produce the FireDAC trace and see what there really happens.

--
With best regards,
Dmitry Arefiev / FireDAC Architect
Trevor Cooper

Posts: 45
Registered: 10/7/10
Re: Error [FireDAC] [DApt] -400: what does it mean?  
Click to report abuse...   Click to reply to this thread Reply
  Posted: Apr 8, 2015 10:50 AM   in response to: Dmitry Arefiev in response to: Dmitry Arefiev
Hi Dmitry,

So I produced the FireDAC trace. Immediately before the error, I see this:

SELECT PROPERTY_ID AS ROWID
FROM ADDRESSPOINTS
WHERE PROPERTY_ID = :NEW_PROPERTY_ID AND PROP_REF = :NEW_PROP_REF AND
PROP_REF_F = :NEW_PROP_REF_F AND BASEMENT = :NEW_BASEMENT AND
BASEMENT_F IS NULL AND EASTING = :NEW_EASTING AND NORTHING = :NEW_NORTHING AND
ADDRESS IS NULL AND ADDRESS_F IS NULL AND NODE_ID = :NEW_NODE_ID AND
MODNODEID = :NEW_MODNODEID AND MODNODEID_F = :NEW_MODNODEID_F AND
BASE_LVL IS NULL AND BASE_LVL_F IS NULL AND PROP_LVL = :NEW_PROP_LVL AND
PROP_LVL_F = :NEW_PROP_LVL_F$#1 AND "KEY" = :NEW_KEY AND
LINK_ID = :NEW_LINK_ID AND LINK_EASTING = :NEW_LINK_EASTING AND
LINK_NORTHING = :NEW_LINK_NORTHING AND MODLINKID = :NEW_MODLINKID AND
MODLINKID_F = :NEW_MODLINKID_F AND MAPINFO_ID IS NULL AND
MOD_LINK_EASTING = :NEW_MOD_LINK_EASTING AND MOD_LINK_NORTHING = :NEW_MOD_LINK_NORTHING AND
LINK_PROXIMITY = :NEW_LINK_PROXIMITY AND MOD_LINK_PROXIMITY = :NEW_MOD_LINK_PROXIMITY AND
PROPERTY_TYPE IS NULL AND NETWORK_ASSIGNMENT_METHOD = :NEW_NETWORK_ASSIGNMENT_METHOD AND
LINK_LEVEL = :NEW_LINK_LEVEL AND MOD_LINK_LEVEL = :NEW_MOD_LINK_LEVEL AND
FLOODING_REPORTED = :NEW_FLOODING_REPORTED AND SELECTED = :NEW_SELECTED AND
CLIENT_FLOOD_RISK IS NULL AND CRITICAL = :NEW_CRITICAL"]
81622178890 18:32:00.402 . [FireDAC][DApt]-400. Update command updated [0] instead of [1] record. Possible reasons: update table does not have PK or row identifier, record has been changed/deleted by another user

So how do I interpret this? In my code, I'm doing a record-by-record update to just two fields in this list. It looks as though FireDAC is converting my record-by-record code into an update query. Is this correct? But if so, why is it selecting the record by matching on all fields, rather than just the one field that constitutes the primary key? How do I tell which field is provoking the error?

If FireDAC is converting everything to a very long series of update queries, would it be more efficient if I rewrote the code as an explicit array DML update query?

Regards

Trevor Cooper
Dmitry Arefiev

Posts: 1,406
Registered: 12/7/03
Re: Error [FireDAC] [DApt] -400: what does it mean?  
Click to report abuse...   Click to reply to this thread Reply
  Posted: Apr 14, 2015 7:32 AM   in response to: Trevor Cooper in response to: Trevor Cooper
Something like that was fixed in past. As a workaround try to set UpdateOptions.RefreshMode to rmManual.

If FireDAC is converting everything to a very long series of update queries, would it be more efficient if I rewrote the code as an explicit array DML update query?

Array DML will be much faster in any case.

--
With best regards,
Dmitry Arefiev / FireDAC Architect
Terry Smith

Posts: 1
Registered: 5/7/08
Re: Error [FireDAC] [DApt] -400: what does it mean?  
Click to report abuse...   Click to reply to this thread Reply
  Posted: Mar 29, 2016 10:52 AM   in response to: Trevor Cooper in response to: Trevor Cooper
Trevor Cooper wrote:
Hi,

I'm running a loop to update the value in a field of each record in a table of 20,000 records in an SQLite database. The entire process is embedded in an explicit transaction. I'm using FireDAC in XE5.

The calculated values come from a specialist component so the operation cannot be carried out as an update SQL.

The loop runs for several thousand records and then fails with an exception that reports '[FireDAC] [DApt] -400. Update command updated [0] instead of [1] record. Possible reasons: update table does not have PK or row identifier, record has been changed/deleted by another user'.

None of these possible reasons is helpful. The table has a primary key, and no other user or process has access to the table while this loop runs. What else can the problem be? There doesn't seem to be anything on this error in the DocWiki. Or is there?

Grateful for any advice.

Trevor Cooper

I'm not sure if this helps but I have encountered the same error message when trying to delete a record immediately after saving it (Windows 7, MS Access 97, Delphi XE7). I found that if I moved off the new record and then moved back to it the subsequent delete operation worked without error. I've implemented a BeforeDelete method that calls FindPrior then FindNext on the dataset. I'd like to think that there is a much neater way of overcoming the problem.
Terry Smith
Juan Pablo Lecocq

Posts: 2
Registered: 1/11/01
Re: Error [FireDAC] [DApt] -400: what does it mean?  
Click to report abuse...   Click to reply to this thread Reply
  Posted: Sep 14, 2017 11:15 AM   in response to: Trevor Cooper in response to: Trevor Cooper
Hi:
Try to set Tfields proprties to
(Autoincrement) arNome
(Keyfield) Blank
(Providerflags) (Update,where,Key,Required all to true)

set key field value in onNewRecord like this 8dont use generator directly write stored proc on database

begin
FDSt_Pr.Prepare;
Try
FDSt_Pr.ExecProc;
FDTblXXX.Value:=FDSt_Pr.Params[0].Value;
finally
FDSt_Pr.UnPrepare;
end;

Trevor Cooper wrote:
Hi,

I'm running a loop to update the value in a field of each record in a table of 20,000 records in an SQLite database. The entire process is embedded in an explicit transaction. I'm using FireDAC in XE5.

The calculated values come from a specialist component so the operation cannot be carried out as an update SQL.

The loop runs for several thousand records and then fails with an exception that reports '[FireDAC] [DApt] -400. Update command updated [0] instead of [1] record. Possible reasons: update table does not have PK or row identifier, record has been changed/deleted by another user'.

None of these possible reasons is helpful. The table has a primary key, and no other user or process has access to the table while this loop runs. What else can the problem be? There doesn't seem to be anything on this error in the DocWiki. Or is there?

Grateful for any advice.

Trevor Cooper
takieddine aoua...

Posts: 1
Registered: 5/1/15
Re: Error [FireDAC] [DApt] -400: what does it mean?  
Click to report abuse...   Click to reply to this thread Reply
  Posted: Feb 14, 2018 6:05 AM   in response to: Trevor Cooper in response to: Trevor Cooper
its happen to me too i solve it by writing the key on -->updateoption-->keyfields
Legend
Helpful Answer (5 pts)
Correct Answer (10 pts)

Server Response from: ETNAJIVE02