Exception in CachedUpdates ApplyUpdates
Posted: Fri 11 May 2012 16:41
I have code that deletes the detail records in a master/detail set of tables. The detail table is in CachedUpdate and I have code that reads:
with Tbl do
begin
DisableControls;
try
First;
while not EOF do
Delete;
if CachedUpdates and UpdatesPending then
begin
ApplyUpdates;
CommitUpdates;
end;
finally
EnableControls;
end;
end;
This gives me an exception in the ApplyUpdates. The MemData.pas, in the ApplyUpdates procedure on line 7205 which reads
if OldCurrentItem.Flag = flUsed then
CurrentItem := OldCurrentItem;
Then OldCurrentItem is nil and so it causes a problem. If I put an:
if OldCurrentItem<>nil
before the lines, it seems to work. Is there any problem with doing this?
Thanks,
with Tbl do
begin
DisableControls;
try
First;
while not EOF do
Delete;
if CachedUpdates and UpdatesPending then
begin
ApplyUpdates;
CommitUpdates;
end;
finally
EnableControls;
end;
end;
This gives me an exception in the ApplyUpdates. The MemData.pas, in the ApplyUpdates procedure on line 7205 which reads
if OldCurrentItem.Flag = flUsed then
CurrentItem := OldCurrentItem;
Then OldCurrentItem is nil and so it causes a problem. If I put an:
if OldCurrentItem<>nil
before the lines, it seems to work. Is there any problem with doing this?
Thanks,