Subject Re: [IBO] A Few Simple Questions
Author Geoff Worboys
> 1. What overhead is involved in a close and open of TIB_Query? The
> reason I ask this is I noticed in some of the examples supplied with
> IBO that when scrolling a master dataset, the detail dataset(those
> in tabs not visible at the time) are closed. The reason I ask this
> is I always thought that opening and closing datasets, especially
> remote, would be time and resource consuming.

It is the prepare phase that is most costly - and even that is not too
bad after the first time, because IBO caches the relevant information.

Close does not necessarily unprepare the dataset and so openning again
is not necessarily that expensive. You will notice lots of provisos,
because the actual results depend on other facts, such as whether you
have AutoFetchAll enabled on a large dataset etc.

Generally the closing a dataset when a tab is not visible simply makes
it faster to scroll the main dataset - because there are less details
to keep in sync.

In my own apps I generally dont even prepare a dataset until the tab
showing the data becomes visible. However I usually dont bother
closing the dataset again, since in my own situations I expect it will
be likely the user is coming back. Exactly what you need to do
depends a great deal on what the application needs to do.

> 2. In most of these examples I could not find a place where datasets
> where explictly closed when the app was closed. Either they are
> closed in the base form(which Jason makes plenty use of), or they
> are automatically closed????

You will generally find that the automatic close is done via the
transaction. For example in the IBO base form you have...

procedure TfrmBase.FormCloseQuery...
ModalResult := BaseTransaction.CloseWithConfirm;
CanClose := ModalResult = mrOk;

Also the destruction of the various components will cancel out any
outstanding transaction.

Commit, rollback or close of a transaction will automatically
post/cancel/close all associated datasets.

Note that cancelling a dataset edit or insert has no impact on the
server itself, because edit / insert modes are purely a client
feature. The server does not know about them until they are posted.
So the only server interaction during close is rollback of an
outstanding transaction.

> 3. I also noticed that refresh's on datasets are done primarily when
> dataset operations(ie Updates etc) are done directly on the server
> and not in the client dataset buffers. I suppose it makes sense that
> if a user is updating the server via the client buffer, a refresh is
> not necessary?????

I am not sure if I understand this question. But try this...

When you post an insert or edit to the server there may be trigger
operations that take place which alter other fields on that record.
So it may be necessary for IBO to re-read the record after it is
posted in order to see those changes.

Generally this interaction is controlled via the BufferSyncroFlags
(telling IBO if it will need to reread the record). However when the
record contains a blob field then the refresh of the record is ALWAYS
performed, because the blobid stored in the record will have changed.


Geoff Worboys
Telesis Computing