Subject Re: [IBO] IBOTable: Record not located for update
Author Lester Caine
Robert Osowiecki wrote:

>>What can be the reason for this error when using plain IBOTable? No
>>Keylinks or other funny stuff...
>>
> I found the reason. The key field is generated by the trigger from
> generator. Since BDE required, that it should have a value, I put 0. It
> seems that unlike BDE, IBObjects do not read back the generated value...
> Is there a way to make it do that?

Client/Server database working is completely different to BDE !
In order to access the record using a value generated in the server, you
need to know what it is. But if you let the server generate it when you
add the record, then you don't know it's value.
SO in order for IBO to be able to handle a new record it has
GeneratorLink, which it uses to get the value from the generator before
it inserts the new record, then it can find the new record to work with
it. The Keylink is the field ( or set of fields ) which can uniquely
identify each record, and is what IBO uses to locate or update a record
in the table.
Since IBO provides a value for the 'keylink' when inserting a new
record, the trigger that was putting the generator value into that field
needs to have an IF NOT NULL so that it does not insert the next
generator value, and 'double step' the numbers used.


CREATE TRIGGER "APPOINTIDINSERT" FOR "APPOINTMENT"
ACTIVE BEFORE INSERT POSITION 0
AS
BEGIN
IF ( NEW.APPOINT_ID IS NULL OR NEW.APPOINT_ID = 0 ) THEN
BEGIN
NEW.APPOINT_ID = GEN_ID(CONTENT_ID_GEN, 1);
END
END

Keylink for the table APPOINTMENT is APPOINT_ID

--
Lester Caine
-----------------------------
L.S.Caine Electronic Services