Problem with master detail relation

Discussion of open issues, suggestions and bugs regarding usage of dbExpress drivers for MySQL in Delphi and C++Builder
Post Reply
TreyThrasher
Posts: 7
Joined: Fri 02 Sep 2011 13:15

Problem with master detail relation

Post by TreyThrasher » Wed 28 Aug 2013 02:34

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?

DemetrionQ
Devart Team
Posts: 271
Joined: Wed 23 Jan 2013 11:21

Re: Problem with master detail relation

Post by DemetrionQ » Thu 29 Aug 2013 15:08

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.

TreyThrasher
Posts: 7
Joined: Fri 02 Sep 2011 13:15

Re: Problem with master detail relation

Post by TreyThrasher » Fri 15 Nov 2013 20:17

(a belated) thank you for your response. It helped me solve this problem.

AndreyZ

Re: Problem with master detail relation

Post by AndreyZ » Mon 18 Nov 2013 10:47

If any other questions come up, please contact us.

Post Reply