Bookmark in TOracle DataSet

Franco

Member
Hi Marco, We have found a problem in Bookmark.
Our program use the bookmark to keep in mind where we was posioned before refreshing a query: to do this we set a bookmark in current position, then we close the dataset and we re-open it.
With Old BDE this method was always working, but with DOA ( that do not get all lines after opening the query) this fail when the boookmark is positioned after the last rows actually read.
I modified the TOracleDataset.InternalGotoBookmark as follows:

procedure TOracleDataset.InternalGotoBookmark(Bookmark: Pointer);
var i,currentposition,j: Integer;
begin
i := FindBookmark(PInteger(Bookmark)^);
if i >= 0 then
FCurRec := i
else
begin
if PInteger(Bookmark)^>= Records.RecordCount then // if the required bookmark is after the available records....
begin // ...it could be a buffer problem
currentposition := FCurRec; // save current position ( probaby at top)
for j := currentposition to PInteger(Bookmark)^ do // try to go forward up to bookmark position
if not eof then // ... by checkin to not run out of file
next;
i := FindBookmark(PInteger(Bookmark)^); // then try again ...
if i >= 0 then // if found ...
FCurRec := i // .. we are ok set the position
else
begin // ...if not.... the bookmark has become invalid
FCurRec := currentposition; // .. so reset position and raise the exception
DatabaseError('Bookmark not found (' + IntToStr(PInteger(Bookmark)^) + ')');
end;
end;
end;
end;

I dont' know if there is a smarter solution: what do you think?

Thank you
Franco
 
If you close/reopen the dataset then there is no guarantee that this is the same record. After all it is just a sequence number.

If you want to ensure that the same record is focused after reopening a dataset you should probably use a key value or rowid for reference.
 
Back
Top