Page 1 of 1

Deleting the last record throws "record not found" or an AV

Posted: Fri 23 Apr 2010 10:43
by h.hasenack
I have a TCLientdataset, a TOraprovader and a TOraTable connected.

When I delete the last (I mean there's only one left) record available in t clientdataset, and call applyupdates an exception is raised from within
  • procedure TMemData.SetToBookmark(Bookmark: PRecBookmark);
I have added the following fix to avoid the error:

Code: Select all

procedure TCustomDADataSet.Resync(Mode: TResyncMode);
begin
  // this need if Resync called for closed dataset (AV BUG !!!)
  // HH Added   and (Data.RecordCount>0)
  if Active and (Data.RecordCount>0) then 
    inherited;
end;
Is this a correct fix? Or am I missing something else here?

Background info:
RAD Studio 2007
Oracle 10g

Regards - Hans

Posted: Mon 26 Apr 2010 13:55
by bork
Hello

I cannot reproduce your issue. When I call ApplyUpdates the application doesn't call the TCustomDADataSet.Resync procedure. Try to remove all event handles from TOraTable and TClientDataset and try to delete the last record from the client dataset again. If exception is raised again then please tell us your TOraTable and TClientDataSet options the default values of which were changed.

Posted: Tue 27 Apr 2010 08:27
by h.hasenack
Hard to reproduce, yes, it may have something to do with the actual layout of the table (BLOB's/CLOB's/indexes and that kind of stuff)

Unfortunately I do not have the time at the moment to build a minicase demonstrating the problem. I'll let you know when I have one.

Meanwhile: Can you predict if my quickfix potentially breaks other code or is it relatively safe (after running some tests at least it appears to be safe)

Kind regards
Hans

Posted: Wed 28 Apr 2010 09:11
by bork
After applying your fix I found the following bug:

- open TOraQuery or TOraTable with 1 record
- delete this record

Record will be deleted from database but record will be kept by dataset until you execute refresh. And next operation with this dataset without refresh can raise unpredictable errors.

I advise you to determine which dataset properties or events reduce to raising this exception and we will fix it.

Posted: Wed 28 Apr 2010 09:39
by h.hasenack
Still had no time to create a simple Delphi project to reproduce this.

But I don't see how can it keep a record when (Data.RecordCount=0)

I actually avoid the doing the resync because the somehow the bookmarks get messed up, and this again causes the Resync call to produce an AV.

Maybe this is useful information: There was DBGrid connected, which causes the TDataset to have multiple record buffers.

Regards - hans

Posted: Thu 29 Apr 2010 11:19
by bork
The problem is that the Data object has no record (Data.RecordCount=0) but the DataSet's buffer has one record and and ReSync synchronizes DataSet's buffers with the Data object, which is actually the records storage.