Subject Re: [IBO] BufferSynchroFlags don't work
Author Radovan Antloga
Hi Helen.

I think I have to explain more about my problem. First message about this
problem was from Torok Zoltan (20.10.2001 1:42). Because I'm migrating from
BDE to IBO and I have the same situations in my applications so I have tested
this also. Lester Caine answered Zoltan with solution:

Use 'GeneratorLinks' for this insert.

I tried that also but problem is still there. The main problem is that
after I insert new record the row disappears from grid. I must Refresh to
see new record but new row is not focused. I have changed trigger as you
suggested but new record still disappears from grid. Test description:

CREATE TABLE EMPDES
(
ID INTEGER NOT NULL,
EMPNO INTEGER,
EMPDESCRIPTION VARCHAR(100),
CONSTRAINT EMPDES_PK PRIMARY KEY (ID)
);

CREATE ASCENDING INDEX EMPDESINDEX1 ON EMPDES (EMPNO, ID);

CREATE EMPDESTRIGGER1 FOR EMPDES
ACTIVE BEFORE INSERT POSITION 0
AS
BEGIN
if (new.ID IS NULL) then
new.ID = gen_id(gID, 1);
END

I have grid and TIBOQuery (IBO 4.2Eg evaluation) with:
AutoFetchAll=False
BufferSynchroFlags=[bsBeforeEdit,bsAfterEdit,bsAfterInsert]
CachedUpdates=False
CommitAction=caInvalidateCursor
GeneratorLinks=(ID=gID)
KeyLinks=(EMPDES.ID)
OrderingItemNo=1
OrderingItems=(EMPNOID=EMPNO,ID)
OrderingLinks=(EMPNOID=1)
ReadOnly=False
RequestLive=True

I can send you test example. In all other situations Refresh works fine.
I think the problem is only when primary key gets new value from
generator on server. I don't care if ID is encremented twice I would
just like to see new record after post in the right position in grid.
Can you tell me what can I do? Thank you in advance !!!!!

Best Regards
Rado Antloga
OK, your problem here is that you are incrementing your generator twice: once with GeneratorLinks and then again in a Before Insert trigger on the server. You need to change your trigger, so that it gets a generator value ONLY if the new.value is NULL.

...if (new.aValue is null) then
new.aValue = Gen_ID(aGenerator, 1);
..

The problem you have at present is that your application "knows" about the key value returned to your GeneratorLinks; but your new record does not have this key value, it has a value that is one higher than that.

Regards,
Helen


[Non-text portions of this message have been removed]