Hello
Hello,
I use FireDac TFDQuery with cachedUpdates = true and Embarcadero Studio 10.2. I want to have aggregates on a calculated field of TFDQuery but when I try to set TFDQuery.Active = true at design time I get the message shown in the attached picture. I placed FireDac.Stan.ExprFuncs on uses clause but problem reamains.
I would like to ask how I could overcome this ?
Thank you
Interesting name of the function "SellTotalCalc". Is this some event handler? Should be "CellTotalCalc"...
ReplyDeleteMichael Tracey Yes in TFDQUery I have a calculated field SellTotalCalc and an aggregate field RsvTotall that is the Sum(SellTotalCalc). When at design time I try to FDQuery.Active true I get the error
ReplyDeleteDany Marmur Is is just a a name I use for a calculated field in a TFDQuery component.
ReplyDeleteI believe Michael is correct. You cannot aggregate calculated fields. Since you are using a cached update, put the initial calculation in SQL and exclude the field from cached updates. (See TField.ProviderFlags.) Then add an OnChange event handler to the TFields contributing to the calculation to update the calculated field. I suggest calling the same method from all TField.OnChange events, e.g. UpdateTotal.
ReplyDeleteKyle Miller I found out that aggrergates works if I change the calculated fields to internalcalc fields. Thanks for the answer.
ReplyDeleteMichael Thuma I found out that aggrergates works if I change the calculated fields to internalcalc fields. Thanks for the answer.
ReplyDeleteNick Lazidis InternalCalc does not throw an error, but you'll be responsible for filling in the values for all records and for all updates to the field when variables change. This is why I recommended what I did. SQL takes care of initial values and TField.OnChange makes sure the field is updated when the user changes a field affecting its value.
ReplyDeleteEither way works. InternalCalc seems like a little more work at run time.