Icon View Incident Report

Serious Serious
Reported By: Bruce Vander Werf
Reported On: 1/6/2004
For: Version 4.01 Build 1
# 1524 Executing Multiple AlterTable Calls Using FieldDefs.Update Calls For Each Can Cause Incorrect Result

When I click the button to run the following AlterTable code, the blob fields are wiped out.

procedure TForm1.BitBtn1Click(Sender: TObject);
var
  FD: TDBISAMFieldDef;
begin
  with tblSongs do
    begin
      TableName := 'WASongs';
      DatabaseName := '';
      if ((UserMajorVersion = 3) and (UserMinorVersion = 0)) then
        begin
          FieldDefs.Update;
          with FieldDefs do
            begin
              FD := Find('USER1');
              if (FD <> nil) then
                FD.Size := 30;
              FD := Find('USER2');
              if (FD <> nil) then
                FD.Size := 30;
              FD := Find('USER3');
              if (FD <> nil) then
                FD.Size := 30;
              FD := Find('ROADMAP');
              if (FD <> nil) then
                FD.Size := 30;
              Insert(23, 26, 'FILELINK1', ftString, 80, false);
              Insert(24, 27, 'FILELINK2', ftString, 80, false);
            end;
          IndexDefs.Update;
          AlterTable (0, 3, 1);
        end;
      if ((UserMajorVersion = 3) and (UserMinorVersion = 1)) then
        begin
          FieldDefs.Update;
          with FieldDefs do
            begin
              FD := Find('ROADMAP');
              if (FD <> nil) then
                FD.Size := 80;
              Insert(25, 28, 'UPDATED', ftDateTime, 0, false);
            end;
          IndexDefs.Update;
          AlterTable (0, 3, 2);
        end;
    end;
end;



Comments Comments and Workarounds
The problem was caused by the second FieldDefs.Update not working properly. The internal TDataSet FieldDefs thought that they didn't need to update after the first AlterTable call even though they did, and subsequently did not cascade an update requirement down to the TDBISAMFieldDefs.


Resolution Resolution
Fixed Problem on 1/12/2004 in version 4.02 build 1
Image