Subject Re: [IBO] KeyLinks and KeyLinksAutoDefine
Author TeamIBO
Artur and Martin,

> When Keylinks are autodefined, I expected IBO to complete the
> KeyLinks field, in one of two ways: using the Primary Key that it
> found or using DB_Key.

That is what should happen - for simple selects.

What we need to do is discover why this does not work in the instances
that you and Martin are experiencing.

I setup a test on the employee database where I did not select the
EMP_NO (primary key) field of the employee table with the following


1. With FetchWholeRows = false I could edit but not insert. This is
because the RDB$DB_KEY field was not included in the main select,
only in the separate keyselect cursor.

2. With FetchWholeRows = true I could edit and insert with the
following restrictions...

* if BufferSynchroFlags.bsAfterInsert was false then I could not
edit the just inserted row until the _dataset_ was refreshed -
because the DB_KEY had not be retrieved from the server.

* if BufferSynchroFlags.bsAfterInsert was true then I could insert
but the row vanished from the grid when it was posted (and only
reappeared after I refreshed). This happens because the "key"
(DB_KEY) is not known prior to the post and so the individual
record cannot be retrieved.

So please note that the TIB_BDataset.SysPrepareSQL code that adds the
DB_KEY will not be called unless FetchWholeRows is true, and insert is
not possible unless that situation is true (and then has the
restrictions as described above).

So far, according to my tests everything is working as expected.
Delphi5, IBO4.2.Fr, Win2KPro SP2, Firebird 1 RC2
my version of the employee.gdb database has been upgraded to dialect
3, but no quote delimited names were used in this testing.

So to resolve this it appears that we need to know what sort of
queries you are doing where this processing fails.
(Dialect, server version, IBO version, Delphi/BCB version etc etc).

Side Note: This is why Jason always insists on demo apps. Even
problems that appear straight forward on the outside are often much
more complex. I have just spent an hour setting up a demo which shows
only that everything is working as I expected in the given situation.
(There are better ways to spend your Sundays :-)

Geoff Worboys - TeamIBO
Telesis Computing