Subject RE: [IBO] A Few Simple Questions
Author Dion
Hi All/Geoff,

Sorry for all of the questions, but generally, I like to understand exactly
why I am doing something(I would love to wade through tons of IBO
code(hopefully someday soon), but time does not allow this).

I am trying to determine a system(plain vanilla initially) of preparing,
opening, closing datasets, committing transactions at the correct times and
places(all in a multi user environment).

1. Opening datasets
This I know how to do.

2. Closing datasets
If I have a simple form which allows editing of a table(using TIB_Query),
can I close it in the forms OnDestroy event. Would/could another method of
closing be used if I had an TIB_Transaction on the form?

3. Preparing TIB_Query
When is this done explicitly. Where can it be be set to be done

4. UnPrepare
Same as above.

Comment:- I noticed in the code(v4.2E) that CommitAction(TIB_Query) is WIP.
Setting this value has no effect then?

Many Thanks,

-----Original Message-----
From: Geoff Worboys [mailto:geoff@...]
Sent: Tuesday, January 01, 2002 4:36 AM
To: Dion
Subject: Re: [IBO] A Few Simple Questions

> 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

IB Objects - direct, complete, custom connectivity to Firebird or InterBase
without the need for BDE, ODBC or any other layer.
___________________________________________________________________________ - your IBO community resource for Tech Info papers,
keyword-searchable FAQ, community code contributions and more !

Your use of Yahoo! Groups is subject to