I'm facing difficulty to find a correct way to get errors on ApplyUpdates method, using FireDAC in memory (CachedUpdates).
Here is my scenario, a master-detail relationship, compounded by:
- 1
TFDConnection - 2
TFDQuery - 2
TDataSource - 1
TFDSchemaAdapter
Both queries are setted as CachedUpdates and are linked to FDSchemaAdapter.
The FDQuery2 (detail) is linked with the master by MasterSource property. MasterFields and IndexFieldNames are setted as "idMaster". The property FetchOptions.DetailCascade is also checked.
I also have a button to perform the apply:
try
FDConnection1.StartTransaction;
FDSchemaAdapter1.ApplyUpdates(0);
FDQuery1.CommitUpdates;
FDQuery2.CommitUpdates;
FDConnection1.Commit;
except on E: Exception do
begin
FDConnection1.Rollback;
raise Exception.CreateFmt('Something went wrong. Error: %s', [E.Message]);
end;
end;
Everything is working fine so far.
The problem occurs when my database throw an exception, such a constraint violation. The exception is not raising. Consequently, my transaction is not 'rollbacked'.
ps: I'm using Delphi XE7 and Firebird 2.5
Notify on language exceptionsis checked under Tools | Options | Debugger Options and thatuse debug dcusis checked under Project | Options. Run the app to where you expect the exception to occur and see if the debugger breaks execution. If it does, use View | Debug windows | Call stack to locate it. - MartynA