0
I am using Delphi 10.1, Firebird 2.5 with Firedac. I have 3 Fdquery, all with Cachedupdates = true, being 1 MASTER, and 2 Detail. In the bd, the FK points to the ID of the master table. In the application, mastersource, Masterfield and Indexfieldname filled as per this link.
I use a Tfdschemaadapter, all 3 Querys have the Schemaadapter field pointing to the Fdschemaadapter1. Until then ok, it works, takes the key at the time of recording and stores in the two query Detail. However, using the code below to permanently save to the comic, from the first attempt it triggers error (1 error for each line in the details), and worse: persists the recording in the MASTER table, and does not record anything in any of the 2 Detail.
Then, I close the form, remaining with the application open, open the form again, put new data in all 3 query, and when firing the code below, it works as expected, triggering 0 error, and works ok all other times.
No error is triggered when I give append, Insert, post.
Where am I going wrong?
//Código do botão para salvar
dm.FDConnection1.StartTransaction;
iErrors := FDSchemaAdapter1.ApplyUpdates;
if iErrors = 0 then
begin
ShowMessage('não deu erros: '+IntToStr(iErrors));
FDSchemaAdapter1.CommitUpdates;
dm.FDConnection1.Commit;
end else
begin
MsgBxErroWarn('Deu erro: '+IntToStr(iErrors));
dm.FDConnection1.Rollback;
end;