Problem with master detail relation
Posted: 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?
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?