Subject | DisableControls with master-detail issue |
---|---|
Author | Salvatore Besso |
Post date | 2005-01-18T19:28:30Z |
hello all,
I have found what I think is a bug. I have uploaded a test case in the Files
section (in the "Bug Testing Applications" folder).
The test database has two tables, PARENT and CHILD, bound with master-detail
relationship. When traversing both tables to update a field into PARENT and
using DisableControls the values written in the updated field of PARENT are
clearly wrong. The test is built with TIB_Queries.
In other words:
begin
try
PARENT.DisableControls;
CHILD.DisableControls;
TR.StartTransaction;
PARENT.First;
while not PARENT.Eof do
begin
Count := 0;
CHILD.First;
while not CHILD.Eof do
begin
if CHILD.FieldByName('DUMMY_TEXT').AsString = 'Count me!' then
Inc(Count);
CHILD.Next
end;
PARENT.Edit;
PARENT.FieldByName('CHILD_COUNT').AsInteger := Count;
PARENT.Post;
PARENT.Next
end;
TR.Commit
finally
PARENT.EnableControls;
CHILD.EnableControls
end
end;
If I comment DisableControls and EnableControls the operation succeeds, instead
if I use them, all the CHILD_COUNT fields in PARENT are updated with the same
value, that seems to always be the count of the CHILD rows for PARENT.ID = 1.
IOW it seems that using DisableControls/EnableControls breaks master-detail
relationship when tables are traversed.
Anyway, download the test case to see it in action.
Thanks
Salvatore
I have found what I think is a bug. I have uploaded a test case in the Files
section (in the "Bug Testing Applications" folder).
The test database has two tables, PARENT and CHILD, bound with master-detail
relationship. When traversing both tables to update a field into PARENT and
using DisableControls the values written in the updated field of PARENT are
clearly wrong. The test is built with TIB_Queries.
In other words:
begin
try
PARENT.DisableControls;
CHILD.DisableControls;
TR.StartTransaction;
PARENT.First;
while not PARENT.Eof do
begin
Count := 0;
CHILD.First;
while not CHILD.Eof do
begin
if CHILD.FieldByName('DUMMY_TEXT').AsString = 'Count me!' then
Inc(Count);
CHILD.Next
end;
PARENT.Edit;
PARENT.FieldByName('CHILD_COUNT').AsInteger := Count;
PARENT.Post;
PARENT.Next
end;
TR.Commit
finally
PARENT.EnableControls;
CHILD.EnableControls
end
end;
If I comment DisableControls and EnableControls the operation succeeds, instead
if I use them, all the CHILD_COUNT fields in PARENT are updated with the same
value, that seems to always be the count of the CHILD rows for PARENT.ID = 1.
IOW it seems that using DisableControls/EnableControls breaks master-detail
relationship when tables are traversed.
Anyway, download the test case to see it in action.
Thanks
Salvatore