Page 1 of 1

Master/details problems when inserting

Posted: Tue 14 Feb 2006 16:23
by schardosin
Hi,

We have just migrated our system from Delphi 4 to Delphi 7 changing all TTable components to TOraTable.

Suppose that I have the fields MyKey and MyDesc into MasterTable and the fields MyKey, MyDetailKey and MyDetailDesc into DetailTable.
First I insert into MasterTable and after I insert into DetailTable, when I execute MasterTable.Post, detailTable.Refresh happen and all detailtable data loses;

One example will be more clean:

DataSource: DataSet = MasterTable
MasterTable: CachedUpdates = True; KeyFields = MyKey
DataSourceDetail: Dataset = DetailTable;
DetailTable: CachedUpdates = True; MasterSource = DataSource; MasterFields = MyKey; DetailFields = MyKey

MasterTable.Insert;
MasterTableMyKey.Value := 1;
MasterTableMyDesc.Value := 'Bla bla bla';

DetailTable.Insert
DetailTableMyKey := 1;
DetailTableMyDetailKey := 1;
DetailTableMyDetailDesc := 'a';
DetailTable.Post;

DetailTable.Insert
DetailTableMyKey := 1;
DetailTableMyDetailKey := 2;
DetailTableMyDetailDesc := 'b';
DetailTable.Post;

MasterTable.Post; //at this moment happen the refresh into DetailTable - Oh god, I lost everything that I wrote



What am I doing Wrong ????

Posted: Wed 15 Feb 2006 14:20
by Challenger
You shouldn't use Master/Detail and CachedUpdates simultaneously. We are going to support this functionality but not in the near future.

Posted: Wed 15 Feb 2006 15:43
by schardosin
What am I going to do with the legacy code ???
It's impossible to migrate everything.

Wouldn't It be more easy the refresh on detailTable to be optional ???

I just don't want that the refresh on Details happen after MasterTable.Post.

Was not TOraTable made to be compatible with TTable ???

Now I've got a terrible headache.

Posted: Mon 20 Feb 2006 14:59
by Challenger
We are not going to make refresh of Detail dataset optional.