Page 1 of 1

Query.CachedUpdates

Posted: 08.05.2009, 14:27
by MainMeat
Hi Everyone,

I have a quick question on the CachedUpdates property that can be set to true on a Query.

What does this property do?
Does it:
1) Cache any updates made to the dataset and does not write the changes to records to disk until ApplyUpdates is called. This means all changes / updates to data in the dataset is cached until ApplyUpdates is called and the updated will remain in memory until this is done.

2) Therefor, does this mean when I insert a new record into a dataset, I have to call ApplyUpdates in order for this record to be stored? (I have found that when not doing this, the new data is not always stored).

Thanks in advance!

Posted: 08.05.2009, 21:25
by mdaems
This property means that communication with the server only happens 'on demand'. Not sure, but I believe closing a dataset also does this.
Normally only changing this option should not have any effect on final data in the database (not taking into account the influence of other sessions on the database).

Concerning
(I have found that when not doing this, the new data is not always stored)
This may be bad behaviour (~ a bug). Difficult to tell with only the data above.

Mark

Posted: 12.05.2009, 09:58
by trupka
I don't thing its a bug, more like feature.
It seems that CachedUpdates resembles behavior of delphi T(BDE|IBX)* components and influences how UpdateObject will work (if assigned).
If CachedUpdates := false then updates will be immediately applied (query will be executed).
If CachedUpdates := true, all updates (chages) will be, well.. cached - not applied to dataset until ApplyUpdates called. This behavior allows to change many records at once, and, in theory, to work "offline". I never tested zeos implementation in details but I think it works...