Subject RE: [IBO] TIBOQuery & CachedUpdates - Insert not working
Author Jason Wharton
> I'm trying to use a simple (TDataset compatible) query with
> CachedUpdates, but I can't get it to work.
> I try:
> Query.Insert
> ...
> Transaction.StartTransaction
> ...
> Query.ApplyUpdates
> ...
> Transaction.Commit
> But nothing gets written to the table.

I recall when designing the behavior of Commit for the transaction to
automatically make sure all datasets that are in an edit state Post so that
the whole transaction is complete. CommitRetaining also has the same
behavior, to cause datasets to Post when in an edit state so that the unit
of work is complete and tidy. If you call SavePoint for the transaction it
simply does that an nothing else. Any datasets in an edit state remain as

Now, that was all determined before I put thought into the situation where
cached updates are being used. In the case where datasets are using cached
updates the behavior of transactions is in a totally different light. Now,
instead of transactions being an integrated part of how the user is directly
interacting with the server (meaning when post is called changes go to the
server directly) and commit means they are making permanent their current
series of interactions; CachedUpdates now has the transaction mechanisms as
purely utility in that all changed are residing in memory and have not gone
to the server yet. Now, in order for all those cached changes to be handled
with integrity the transaction mechanisms are employed so that all the
cached updates are applied as a single batch of changes or they all fail

Thus, I changed the behavior of Commit and CommitRetaining to not Post a
dataset automatically if it is using CachedUpdates because instead of it
being a part of their interactions it is now only a mechanism under the hood
to deal with cached updates. If you want your dataset to Post you have to
do it yourself when using cached updates.

In your specific case here, your dataset is still in the Insert state and
nothing has gone into the cached updates buffers.

The reason I spelled this out so verbose is because of the difference in
behavior on transactions. It is highly likely many of you familiar with
IBO's behavior to post datasets when calling commit would have expected it
to do so here, when in fact it won't.