Subject cached update for TIBOTable
Author innoy1k
Hi there,

I'm using Delphi 7 and IBObjects 4 with Firebird 1.0.
I am having a problem with TIBOTable cached updates. I could not make
it work as I expected.

I have two applications.
Start the first application, it opens a table, the salutation column
has value "change11-1".

Start the second application, it updates the same column value to
"change12-1" and commits the change to the db. I can see the change in
the table through IBConsole.

Back to the first application, change the same column value from
"change11-1" to "new value" and post and commit it. The OnUpdateError
event is triggered. In the event handler, I set UpdateAction to
uaApplied. I'm expecting "new value" be committed to the db. But it is
not.

I set TIBODatabase.isolation to tiConcurrency, AutoCommit to false.
TIBOTable.CachedUpdates to true. See the following code:

procedure TForm1.IBOTable1AfterPost(DataSet: TDataSet);
begin
IBOTable1.ApplyUpdates;
end;
procedure TForm1.IBOTable1UpdateError(DataSet: TDataSet; E:
EDatabaseError;
UpdateKind: TUpdateKind; var UpdateAction: TUpdateAction);
begin
UpdateAction := uaApplied;
IBODatabase1.Commit;
end;

My understanding is: If I set UpdateAction to uaApplied, my change
will be committed to db, if I set it to uaAbort, my change will be
discarded.

Is my understanding correct? Why my change is not commited to the db?
Thanks,

PS.

This is the code for the first application:

procedure TForm1.Button1Click(Sender: TObject);
begin
IBOTable1.Post;
end;
procedure TForm1.IBOTable1UpdateError(DataSet: TDataSet; E:
EDatabaseError;
UpdateKind: TUpdateKind; var UpdateAction: TUpdateAction);
begin
showmessage('???????????????UpdateError - '+#13#13+E.message);
UpdateAction := uaApplied;
IBODatabase1.Commit;
end;
procedure TForm1.IBOTable1AfterPost(DataSet: TDataSet);
begin
IBOTable1.ApplyUpdates();
end;
procedure TForm1.FormShow(Sender: TObject);
begin
IBOTable1.Open;
end;

This is the code for the second application:

procedure TForm1.Button1Click(Sender: TObject);
begin
screen.cursor := crhourglass;
try
IBOQuery1.SQL.Clear;
IBOQuery1.SQL.Add('update client set salutation =
'+''''+Edit1.text+'-1'+''''+' where number = '+''''+' 1'+'''');
IBOQuery1.ExecSQL;
IBOQuery1.SQL.Clear;
IBOQuery1.SQL.Add('update client set salutation =
'+''''+Edit1.text+'-2'+''''+' where number = '+''''+' 2'+'''');
IBOQuery1.ExecSQL;
IBOQuery1.SQL.Clear;
IBOQuery1.SQL.Add('update client set salutation =
'+''''+Edit1.text+'-3'+''''+' where number = '+''''+' 3'+'''');
IBOQuery1.ExecSQL;
IBOQuery1.SQL.Clear;
IBOQuery1.SQL.Add('update client set salutation =
'+''''+Edit1.text+'-4'+''''+' where number = '+''''+' 4'+'''');
IBOQuery1.ExecSQL;
IBOQuery1.SQL.Clear;
IBOQuery1.SQL.Add('update client set salutation =
'+''''+Edit1.text+'-5'+''''+' where number = '+''''+' 5'+'''');
IBOQuery1.ExecSQL;
IBODatabase1.Commit;
finally
screen.cursor := crdefault;
end;
end;