Subject Re: [IBO] TIBODataset not working in cached updates mode with calc. fields
Author Nando Dessena
I wrote:

N> I have a TIBOQuery with CachedUpdates = True, RequestLive = False and
N> some code in the OnUpdateRecord handler. The intent is to do the
N> updates in a custom way via the OnUpdateRecord.

N> ApplyUpdates is called once for each modified record:

N> procedure TForm1.QyEmployeeAfterPost(DataSet: TDataSet);
N> begin
N> try
N> QyEmployee.ApplyUpdates;
N> except
N> QyEmployee.CancelUpdates;
N> raise;
N> end;
N> QyEmployee.CommitUpdates;
N> end;

N> The sequence of operations is Open, Edit, Post.

N> If (and only if) the dataset happens to have one or more lookup or calculated
N> fields, then it blows up during the post (to be precise, during the
N> applyupdates) saying that "the dataset is not in edit or insert mode".
N> The code that triggers this weird error message seems to be here:

N> procedure TIBODataset.DoUpdateRecord( UpdateKind: TIB_UpdateKind;
N> var UpdateAction: TIB_UpdateAction );
N> begin
N> if CachedUpdates and ( CalcFieldsSize > 0 ) then
N> CalculateFields( TempBuffer );
N> end;

N> Here CalculateFields is called without first putting the dataset in
N> dsCalcFields state, which causes the error.

N> I have a simple test case (using employee.gdb) that I can send in case
N> I have not made it clear enough.

BTW, why is it necessary to calculate the field values before each
record update in cached updates mode? The BDE VCL doesn't do it.

Ciao
--
Nando mailto:nandod@...