Subject Re: [IBO] KeyLinks and KeyLinksAutoDefine
Author TeamIBO
> You know what they say about 'assuming'? You make an 'ass' out
> of 'u' and 'me'... :) (ok, no offence)

None taken, of course with limited information provided I either have
to make assumptions or not bother answering.

> Back to the subject:
> No, I don't ... I use IBO in InterBase Workbench and people just
> enter their SQL statements and press 'run'. So I really have no
> control over the key links...

From your signature it appears you are associated with the development
of Workbench - in which case you could add some level of control to
this situation. However...

> But I guess I can create the variation and put in DB_KEY in the
> select myself - but why isn't IBO doing this? When I did my tests
> with the statement, I couldn't find DB_KEY in the select list...
> When does IBO put DB_KEY in the select (I have seen it happen) and
> when does it not? (and why)

There is an explanation of DB_Key at Claudio's website...

If you take another look at the code in IBA_Dataset.IMP for
function TIB_Dataset.GetKeyLinks: TIB_StringList;

it appears to me that (when KeyLinksAutoDefine is on) IBO attempts to
validate that the keylinks exist in the select. If they dont exist
then the primary key keylinks are cleared - and if this happens the
DB_KEY should be used.

What we need to find out is why this capability is not functioning in
your instance. And for this we will need some help from you to
determine what is going wrong in the instances you are having
problems. For this purpose I would like you to...

1. put a breakpoint in the above method and see what keylinks are
being added in the instance in question.

2. if DB_KEY is being used in the above, then you may also need to put
a breakpoint in the IBA_BDataset.IMP unit, the method:
procedure TIB_BDataset.SysPrepareSQL;

You will see in that method where the DB_KEY should be added to the

If you can tell us which part of this is failing we may have some idea
how the issue can be resolved without any changes being required to

Geoff Worboys - TeamIBO
Telesis Computing