79233641

Date: 2024-11-28 11:21:51
Score: 1.5
Natty:
Report link

All requested functionality is provided by FireDAC's component named TFDSchemaAdapter. This component handles all id assignments.

Delphi documentantion: https://docwiki.embarcadero.com/Libraries/Sydney/en/FireDAC.Comp.Client.TFDSchemaAdapter

Examples: https://docwiki.embarcadero.com/CodeExamples/Athens/en/FireDAC.SchemaAdapterMemTable_Sample

Or examples on GitHub: https://github.com/Embarcadero/RADStudio12Demos/tree/main/Object%20Pascal/Database/FireDAC/Samples/Comp%20Layer/TFDQuery/CachedUpdates/Centralized

Very simple snippet showing data saving do db, once everything is set according manual above:

 if FDSchemaAdapter1.UpdatesPending then
  begin
    FDSchemaAdapter1.ApplyUpdates; //applies correct IDs to all binded queries
    FDQuery1.CommitUpdates;
    FDQuery2.CommitUpdates;
    FDQuery3.CommitUpdates;
  end;
Reasons:
  • Probably link only (1):
  • Has code block (-0.5):
  • Self-answer (0.5):
  • Low reputation (0.5):
Posted by: Aleš