0
votes

I have two tables in a master Detail relationship. Using TFDTables. I display the detail table in a TDBGrid

When I call up the master table I can successfully create one detail record. When I try to add a second the problem starts.

The system does post the second record to the database but when it adds a new line for the thrid record in the detail grid it fills it with the information from the second record. Changing this third records generates an error:

Project xyz.exe raised exception class EFDDBEngineException with message '[FireDAC][Phys][FB]-312. Exact update affected [2] rows, while [1] was requested'.

Further when I click ok in Delphi's debugger it brings up:

Project xyz.exe raised exception class EFDException with message '[FireDAC][DApt]-400. Update command updated [2] instead of [1] record. Possible reasons: update table does not have a PK or row identifier, record has been changed/deleted by another user'.

But the changes do get stored in the database as if I changed the second record and the second record in the grid also reflects what is entered in the third record) I realize these are being generated as it tries update the third record which does not exist.

When I shut down the program and check the database there are only two records in the database at the saved point of the last post before the error. When I reopen the application the grid show three records with the second and third being identical.

Any help or ideas would be greatly appreciated.

Farley

1
Not that it answers the question, but I was able to workaround this by switching to a TFDQuery for the detail table. Farleyfarley
Does the table have a PK or not?MartynA
Hi MartynA - it does have a PK a unigue integer that is generated.farley

1 Answers

0
votes

Probably UpdateOptions.KayFields and UpdateOptions.UpdateTableName will help you. Spacify PK field(s) name in KeyFields and table name in UpdateTableName property of TFDTable.