Page 1 of 1

Error on double ApplyUpdates

Posted: 10.06.2014, 19:35
by andrem

Code: Select all

procedure TZAbstractCachedResultSet.PostUpdatesCached;
var
  i: Integer;
begin
  CheckClosed;
  if FInitialRowsList.Count > 0 then
  begin
    i := 0;
    while i < FInitialRowsList.Count do
    begin
      OldRowAccessor.RowBuffer := PZRowBuffer(FInitialRowsList[i]);
      NewRowAccessor.RowBuffer := PZRowBuffer(FCurrentRowsList[i]);
      Inc(i);

      { Updates default field values. }
      if NewRowAccessor.RowBuffer.UpdateType = utInserted then
        CalculateRowDefaults(NewRowAccessor);

      { Posts row updates. }
      PostRowUpdates(OldRowAccessor, NewRowAccessor);
{MikhailovAP -- ??? } 
      { If post was Ok - update the row update type. }
      if NewRowAccessor.RowBuffer.UpdateType <> utDeleted then
      begin
        NewRowAccessor.RowBuffer.UpdateType := utUnmodified;
        if (FSelectedRow <> nil)
          and (FSelectedRow.Index = NewRowAccessor.RowBuffer.Index) then
          FSelectedRow.UpdateType := utUnmodified;
      end;
    end;
{??? - Reset UpdateType after success}
  end;
end;
Program inserts one record (AutoCommit == off), but no commit. Method DataSet.ApplyUpdates involves again after next manipulation. Has error: primary key.
Copy/paste code block resolves this problem (may be?)