I've been using aggregates in TClientDataSet to keep track of things such as non-autoinc record ids, by having a MAX(idRec) aggregate and then filling the idRec field from this aggregate in the OnNewRecord event of the dataset.

I've been using aggregates in TClientDataSet to keep track of things such as non-autoinc record ids, by having a MAX(idRec) aggregate and then filling the idRec field from this aggregate in the OnNewRecord event of the dataset.

However this approach does not work in FireDAC, because FireDAC does not maintain aggregates in the dsInsert state, so the aggregate values are not available in the OnNewRecord.

I guess I could cache the aggregate value in the OnAfterOpen and OnAfterPost events, but I'd like to know if anyone knows of a smoother approach for FireDAC.

Comments