I suggest some tweaks:
unit ZDbcCachedResultSet;
Code: Select all
TZAbstractCachedResultSet = class (TZAbstractResultSet, IZCachedResultSet)
private
FFetchedRow: PZRowBuffer; // buffer for last fetched row
//...
procedure TZAbstractCachedResultSet.Close;
//...
if Assigned(FRowAccessor) then
begin
if (ResultSetType = rtForwardOnly) and Assigned(FFetchedRow) then
begin
// dispose previous row buffer
FRowAccessor.DisposeBuffer(FFetchedRow);
FFetchedRow := nil;
end;
//...
function TZAbstractCachedResultSet.MoveAbsolute(Row: Integer): Boolean;
//...
if (Row >= 1) and (Row <= LastRowNo) then
begin
Result := True;
if (ResultSetType = rtForwardOnly) then
FSelectedRow := FFetchedRow
else
FSelectedRow := PZRowBuffer(FRowsList[Row - 1]);
RowAccessor.RowBuffer := FSelectedRow;
//...
function TZAbstractCachedResultSet.RowUpdated: Boolean;
function TZAbstractCachedResultSet.RowInserted: Boolean;
function TZAbstractCachedResultSet.RowDeleted: Boolean;
//...
if (RowNo >= 1) and (RowNo <= LastRowNo) then
begin
if (ResultSetType = rtForwardOnly) then
CurrentRow := FFetchedRow
else
CurrentRow := PZRowBuffer(FRowsList[RowNo - 1]);
Result := Assigned(CurrentRow) and (CurrentRow^.UpdateType = utModified);
Result := Assigned(CurrentRow) and (CurrentRow^.UpdateType = utInserted);
Result := Assigned(CurrentRow) and (CurrentRow^.UpdateType = utDeleted);
//...
function TZCachedResultSet.Fetch: Boolean;
//...
TempRow := RowAccessor.RowBuffer;
try
if (ResultSetType = rtForwardOnly) and Assigned(FFetchedRow) then
begin
// dispose previous row buffer
RowAccessor.DisposeBuffer(FFetchedRow);
FFetchedRow := nil;
end;
//...
if (ResultSetType = rtForwardOnly) then
begin
FFetchedRow := RowAccessor.RowBuffer;
LastRowNo := LastRowNo + 1;
end
else
begin
RowsList.Add(RowAccessor.RowBuffer);
LastRowNo := RowsList.Count;
end;
//...
unit ZDbcSqLiteStatement;
Code: Select all
function TZSQLiteStatement.CreateResultSet()
function TZSQLiteCAPIPreparedStatement.CreateResultSet()
//...
if Self.ResultSetType <> rtForwardOnly then
begin
{ Fetches all rows to prevent blocking. }
CachedResultSet.SetType(rtScrollInsensitive);
CachedResultSet.Last;
CachedResultSet.BeforeFirst;
end;
CachedResultSet.SetConcurrency(GetResultSetConcurrency);
//...