Page 1 of 1

Problem with master detail relation

Posted: Wed 28 Aug 2013 02:34
by TreyThrasher
I am not sure whether this is the correct forum for this question but I am not sure where else to start.
I am using Delphi XE and the devart MySQL driver (I believe 4.7)
I have a master table with the structure:
Table Name: Codes
RNO : Integer; (Key)
Code: varchar(8);

I have a child table with the structure:
Table Name: CodeFees
Code: varchar(8) (key)
SequenceNumber: SmallInt (Key)
FeeAmount: Decimal (6,2)
FeeDescription: Text:


The master table has a sqldataset with commandtext select * from Codes;
It has a linked provider and linked clientdataset.

The child table has a sqldataset with commandtext select * from CodeFees where Code =:Code;
It has a linked provider and a linked clientdataset. The clientdataset has the master's datasource as its Mastersource and the code field as its masterfield.

I have put datagrids so that I can browse the master and child table data.

When I run my application, everything thing works as expected if I browse the master table the appropriate child records are shown. Also if I change the value of the code field in the master table the appropriate child records are shown in the child table. If, however, I insert a new master record and enter a value in the code field, the records in the child record are not updated. If I post the record and browse back to it, the appropriate records are shown and I can change the value of the code field and the child records will update as appropriate. (I have created a reduced version of this part of my application just to test this problem so I know that there is nothing else involved in this problem)

Is this the expected behavior in this situation? If so, how can I change the behavior so that the child records are updated when a user is inserting a new record?

Re: Problem with master detail relation

Posted: Thu 29 Aug 2013 15:08
by DemetrionQ
Hello.

This is a specificity of the dbExpress engine behaviour, and it doesn't depend on a used driver. When inserting a new record to the master dataset, the detail dataset is updated on calling the MasterClientDataSet.Post command. The detailed information about the dbExpress engine functioning can be found in the Embarcadero documentation.

Re: Problem with master detail relation

Posted: Fri 15 Nov 2013 20:17
by TreyThrasher
(a belated) thank you for your response. It helped me solve this problem.

Re: Problem with master detail relation

Posted: Mon 18 Nov 2013 10:47
by AndreyZ
If any other questions come up, please contact us.