It is simply just to store temporary data, process this data, then display the results to users.
So... TBufDataset.
I need to sum this column, to do this, must loop the entire records, but looping the entire records on the dataset will triggers lots of methods, such as before post, on calculated, etc.
YIKES. Are you saying you do a count on the client side just to get a sum for a column?
I (now) understand that you are a beginner in database development, and there is nothing wrong with that.
But if you would have stated that from the beginning we could have steered you in a better direction.
Especially if you are doing a SELECT * FROM TABLE and want to display a count/sum, and be responsive with Firebird over a high latency connection like the internet, that's absolutely NOT the way to go. This is really really really inefficient.
With a slow connection what you want to do is not show all 100 or 1000 (or 10.000) records. You only want to retrieve the records that are visible (in a TDBGrid) on screen. And during scrolling, more records are retrieved. That's done automatically. If you need a count or sum then you do a separate SELECT SUM(AMOUNT), COUNT(*) FROM TABLE so you can show the sum and count separately.
You can still do a SELECT * FROM TABLE (although specifying the fields is more efficient) and the TIBQuery will do the caching automatically and only retrieve the needed records. But if you are doing a
while not dataset.EOF or a
dataset.Last then ALL records are retrieved immediately, resulting in a MAJOR slowdown, and you don't want that.
To avoid trigger those methods & events, I copied values of that column to temporary table and do same processing, then display the result in a formated value, 1000 will be displayed as 1,000.
Even with that method... ALL the records need to be retrieved. You don't do that in a database program for the reason stated above.
Above method does take some getting use to but it's much better than using a virtual database or doing a loop through ALL the records.
(if you have 1000 or more records, your method would become unbearable slow over the internet, even with a memory table.)
I hope that the explanation above is clear otherwise feel free to ask questions.