Icon View Incident Report

Serious Serious
Reported By: Terry Swiers
Reported On: 11/10/2014
For: Version 2.18 Build 1
# 4125 Attempting to Delete a Row that Has Been Buffered by the TDataSet Layer Can Cause #601 Error

Steps to reproduce the error are to compile and run the following code, click the "Show Error" button. It will throw up the following error message on the table delete function call:

"ElevateDB Error #601 The table AR is corrupt (The index Unposted is missing a required key)"

procedure TForm10.Button1Click(Sender: TObject);

  procedure SetUnposted;
  var
  Q : TEDBQuery;
  begin
  Q := GetQueryObject;
  Q.SQL.Text := 'update ar set unposted = 1 where transtype = 4 and transnum = 1';
  Q.ExecSQL;
  Q.Free;
  end;

var
T1: TEDBTable;
begin

T1 := GetTableObject('AR');
T1.IndexName := 'CustNum';
T1.Open;
T1.SetRange([1], [1]);

try
T1.Database.StartTransaction(EmptyEDBStringsArray);

T1.Locate('TransType;TransNum', VarArrayOf([4, 1]), []);

SetUnposted;
//SetUnposted; //Not sure if the second call is required, but it simulates our code if there are multiple references for the record being deleted

T1.Delete; //>>> the error will show up here
T1.Database.Rollback; //This is intentional just to make sure the database isn't accidentaly modified and can't reproduce any more.
except
on E: Exception do begin
  T1.Database.Rollback;
  ShowMessage(E.Message);
  end;
end;

T1.Free;
end;

procedure TForm10.EDBSession1BeforeConnect(Sender: TObject);
begin
EDBSession1.LocalConfigPath := ExtractFilePath(ParamStr(0));
end;

procedure TForm10.EDBSession1Login(Sender: TObject; var UserName,
  Password: string; var Continue: Boolean);
begin
UserName := 'administrator';
Password := 'EDBDefault';
end;

function TForm10.GetQueryObject: TEDBQuery;
begin
Result := TEDBQuery.Create(nil);
_SetConnectionInfo(Result);
end;

function TForm10.GetTableObject(TableName: String): TEDBTable;
begin
Result := TEDBTable.Create(nil);
_SetConnectionInfo(Result);
Result.TableName := 'AR';
end;

procedure TForm10._SetConnectionInfo(Obj: TEDBDBDataSet);
begin
SetConnectionInfo(Obj);
end;

procedure SetConnectionInfo(Obj: TEDBDBDataSet);
begin
Obj.SessionName := Unit1.Form10.EDBDatabase1.SessionName;
Obj.DatabaseName := Unit1.Form10.EDBDatabase1.DatabaseName;
end;



Comments Comments
The problem was caused by ElevateDB not forcing a row modification check after the TDataSet layer had buffered the row during the Locate operation and the UPDATE statement had changed the row so that it modified one or more indexes.

ElevateDB now handles this like an optimistic update, causing an:

"ElevateDB Error #1008 The row has been modified since last cached for the table AR"

error message instead when the deletion is attempted.


Resolution Resolution
Fixed Problem on 11/12/2014 in version 2.18 build 2


Products Affected Products Affected
ElevateDB Additional Software and Utilities
ElevateDB DAC Client-Server
ElevateDB DAC Client-Server with Source
ElevateDB DAC Standard
ElevateDB DAC Standard with Source
ElevateDB DAC Trial
ElevateDB LCL Standard with Source
ElevateDB PHP Standard
ElevateDB PHP Standard with Source
ElevateDB PHP Trial
ElevateDB VCL Client-Server
ElevateDB VCL Client-Server with Source
ElevateDB VCL Standard
ElevateDB VCL Standard with Source
ElevateDB VCL Trial

Image