Icon View Incident Report

Serious Serious
Reported By: Oliver Bock
Reported On: 6/3/2005
For: Version 4.21 Build 1
# 2068 SQL DELETE Queries Can Produce Incorrect Record Counts

RecordCount wrong in some circumstances. See below.

On my system (Delphi 7.1), RecordCount ends up as 1, but EOF is True. RecordCount should be zero because the last line of SQL deletes everything from the memory table. I could not simplify the code further.

var
   db: TDBISAMDatabase;
   tbl: TDBISAMTable;
   procedure Exec(sql: string);
   var
      qry: TDBISAMQuery;
   begin
      qry := TDBISAMQuery.Create(db);
      qry.DatabaseName := db.DatabaseName;
      qry.SQL.Add(sql);
      qry.ExecSQL;
      qry.Destroy;
   end;
begin
   db := nil;
   tbl := nil;
   try
      db := TDBISAMDatabase.Create(nil);
      db.DatabaseName := 'Sample';
      db.Connected := True;

      Exec(
    ' create table "\Memory\RA_NewChanged"(ResourceID integer);'+
    ' insert into "\Memory\RA_NewChanged" values(168);'+
    ' delete from "\Memory\RA_NewChanged";'+
    ' insert into "\Memory\RA_NewChanged"'+
    ' select ResourceID'+
      ' from Resource;'+
    ' delete from "\Memory\RA_NewChanged"');


      tbl := TDBISAMTable.Create(db);
      tbl.DatabaseName := 'Memory';
      tbl.TableName := 'RA_NewChanged';
      tbl.Open;
      if tbl.RecordCount > 0 then
         Assert(not tbl.EOF);
   finally
      tbl.Free;
      db.Free;
   end;
end.



Comments Comments
The problem only occurred during SQL DELETE queries when DBISAM internally is using raw record I/O. Deletes using navigational methods did not have this issue.


Resolution Resolution
Fixed Problem on 6/3/2005 in version 4.21 build 2


Products Affected Products Affected
DBISAM Additional Software and Utilities
DBISAM CLX Client-Server
DBISAM CLX Client-Server with Source
DBISAM CLX Standard
DBISAM CLX Standard with Source
DBISAM ODBC Client-Server
DBISAM ODBC Client-Server with Source
DBISAM ODBC Standard
DBISAM ODBC Standard with Source
DBISAM VCL Client-Server
DBISAM VCL Client-Server with Source
DBISAM VCL Standard
DBISAM VCL Standard with Source

Image