Subject Re: [IBO] Optimizing IBO-app: Lookups
Author Helen Borrie
At 05:18 PM 29/03/2003 +0000, you wrote:
>I've written a rather complex two-tiered application using IBO/Firebird.
>I've noticed that it tends to become a bit slow on networks, and now
>I'm trying to reduce the network usage. As it contains a lot of
>lookups that aren't updated very frequently I'm thinking of storing
>the lookup-lists in local files that are synchronized every time a
>connection to the database server is established. What is the best way
>to achieve this? I'm using the IBO controls throughout the entire
>application and I have Delphi 7.

It's not a good idea *at all* to physically separate the lookup data from
the database.

What I do in such cases is to implement the lookup using TIB_ComboBox. I
use an IB_Cursor to fetch the lookup dataset and I have a procedure which
loads the combobox on demand.

This procedure does the following:
1. creates an ib_cursor for the lookup set
2. clears the combo's Items[]
3. calls First on the ib_cursor
4. scans through the cursor and
a) adds the display column to the combo's Items[]
b) add the unique key column to the items ItemValues[]
5. frees the ib_cursor

This is a generic procedure which accepts as arguments a tib_combobox
object, a string for the ib_cursor's SQL and a boolean Refresh flag. If
Refresh is false and the Items.Count of the combobox is > 0 the procedure
just exits without doing anything.

It is called on demand. Generally, this means I call it for each
ib_combobox which I want to populate, during FormCreate of the actual form
containing the combobox. However, if you have the controls on different
tabsheets of a tabbed control, you can defer it until the OnChange event of
that control. If you have lookup data that might need refreshing during a
user session, you can provide a Refresh button and call the procedure with
Refresh true.

I generally have an explicit transaction that I keep just for "hit-and-run"
operations like this; but you could create a transaction on-the-fly if you