Subject | Cached Updates Bug Found and Fixed |
---|---|
Author | Jason Wharton |
Post date | 2004-09-24T09:55:01Z |
Thanks to the assistance of Carlos Cantu and a full day's work on this
problem, I discovered that cached updates were not working in the
TIBODataset components. Some of you knew that already but I was stubborn...
shame shame shame on me.
There was also a problem in regard to having cached updates in conjunction
with master-detail relationships. It was showing the inserted detail
records regardless of which master record was scrolled to rather than
keeping it associated with the properly linked master record. Keep in mind
all other component sets BDE, IBX, FIB, etc. silently cancel the updates in
a detail dataset if the master scrolls.
For this to work more perfectly I had to plumb in a new event that allows
you to pass back a reference "var ShowRecord: boolean" to tell if the detail
record belongs to the current master record or not.
In the case of Carlos' app, here is what the events looked like:
procedure TForm1.DetailCheckCachedInsert(ADataset: TDataSet;
var ShowRecord: Boolean);
begin
ShowRecord := DetailID.AsInteger = MasterPK.AsInteger;
end;
Also notice the similarity here:
procedure TForm1.DetailNewRecord(DataSet: TDataSet);
begin
DetailID.AsInteger := MasterPK.AsInteger;
end;
He was using a relationship between master and detail that I never could
have guessed or parsed.
I also made sure it worked together with calculated fields too, which was a
bear.
The main problem I cleared up was if you had exceptions during the applying
of updates it was possible to have updates in the buffer get ignored the
next time an attempt to apply the updates was made. It should be totally
correct now.
I'm very sorry I let a bug like this stand for as long as I did.
Jason Wharton
problem, I discovered that cached updates were not working in the
TIBODataset components. Some of you knew that already but I was stubborn...
shame shame shame on me.
There was also a problem in regard to having cached updates in conjunction
with master-detail relationships. It was showing the inserted detail
records regardless of which master record was scrolled to rather than
keeping it associated with the properly linked master record. Keep in mind
all other component sets BDE, IBX, FIB, etc. silently cancel the updates in
a detail dataset if the master scrolls.
For this to work more perfectly I had to plumb in a new event that allows
you to pass back a reference "var ShowRecord: boolean" to tell if the detail
record belongs to the current master record or not.
In the case of Carlos' app, here is what the events looked like:
procedure TForm1.DetailCheckCachedInsert(ADataset: TDataSet;
var ShowRecord: Boolean);
begin
ShowRecord := DetailID.AsInteger = MasterPK.AsInteger;
end;
Also notice the similarity here:
procedure TForm1.DetailNewRecord(DataSet: TDataSet);
begin
DetailID.AsInteger := MasterPK.AsInteger;
end;
He was using a relationship between master and detail that I never could
have guessed or parsed.
I also made sure it worked together with calculated fields too, which was a
bear.
The main problem I cleared up was if you had exceptions during the applying
of updates it was possible to have updates in the buffer get ignored the
next time an attempt to apply the updates was made. It should be totally
correct now.
I'm very sorry I let a bug like this stand for as long as I did.
Jason Wharton