Watch, Follow, &
Connect with Us

Please visit our new home
community.embarcadero.com.


Welcome, Guest
Guest Settings
Help

Thread: TFDTable Master/Detail MasterTable post does not post DetailTables



Permlink Replies: 2 - Last Post: Apr 18, 2018 10:41 AM Last Post By: Francisco Arman...
Nils Schneider

Posts: 2
Registered: 11/15/09
TFDTable Master/Detail MasterTable post does not post DetailTables
Click to report abuse...   Click to reply to this thread Reply
  Posted: Apr 5, 2018 3:16 AM
Hello together,

i worked with Master/Detail Tables a few month ago.
I remember, when i posted the MasterTable to the database, all modified DetailTables were posted too.

Now, a few month later, after some Delphi and FireDAC updates, it does not work anymore.
I did not change anything, i just wanted to continue this project.

Does someone have an idea to this issue?

The IndexFieldNames, MasterFIelds and MasterSource properties are set for the DetailTables.

In my desperation i tried out some things and recognized, when i post one of the DetailTables to the database, instead of the MasterTable, the MasterTable is postet too.

I would be happy to get some help.

Greetings, Nils.
Nils Schneider

Posts: 2
Registered: 11/15/09
Re: TFDTable Master/Detail MasterTable post does not post DetailTables
Click to report abuse...   Click to reply to this thread Reply
  Posted: Apr 6, 2018 12:05 AM   in response to: Nils Schneider in response to: Nils Schneider
Maybe someone can halp me, with some more informations.

Actuall Versions:

Delphi: RAD Studio 10.2
FireDAC: 6.0.0 (Build 88974)

Versions with working functionality

Delphi: RAD Studio XE7
FireDAC = 11.0.1 (Build 73709)

I rebuild an application with the older versions.

There are one FDConnection and WaitCursor, two FDTables and two DataSources.
One button to add records to the tables and apply the changes to the Database.

Code looks like:

procedure TForm4.Button2Click(Sender: TObject);
begin
tbMaster.CachedUpdates := true;
tbDetail.CachedUpdates := true;

tbMaster.Append;
tbDetail.Append;

tbMaster.FieldByName('ID').AsString := Edit1.Text;
tbMaster.FieldByName('MASTER_INFO').AsString := 'master' + Edit1.Text;

tbDetail.FieldByName('MASTER_ID').AsString := Edit1.Text;
tbDetail.FieldByName('DETAIL_INFO').AsString := 'detail' + Edit1.Text;

tbMaster.ApplyUpdates;

tbMaster.CommitUpdates;
tbDetail.CommitUpdates;

tbMaster.CachedUpdates := false;
tbDetail.CachedUpdates := false;
end;

When i do this with the older versions, the tbDetails data are posted to the Database too.

I build the same application with the newer versions and there it is necessary to do a tbDetails.Post, otherwise these data will not be posted to the database.

Does someone have an idea, please?

Greetings, Nils.
Francisco Arman...

Posts: 11
Registered: 3/3/01
Re: TFDTable Master/Detail MasterTable post does not post DetailTables
Click to report abuse...   Click to reply to this thread Reply
  Posted: Apr 18, 2018 10:39 AM   in response to: Nils Schneider in response to: Nils Schneider
Nils Schneider wrote:
Maybe someone can halp me, with some more informations.

Actuall Versions:

Delphi: RAD Studio 10.2
FireDAC: 6.0.0 (Build 88974)

Versions with working functionality

Delphi: RAD Studio XE7
FireDAC = 11.0.1 (Build 73709)

I rebuild an application with the older versions.

There are one FDConnection and WaitCursor, two FDTables and two DataSources.
One button to add records to the tables and apply the changes to the Database.

Code looks like:

procedure TForm4.Button2Click(Sender: TObject);
begin
tbMaster.CachedUpdates := true;
tbDetail.CachedUpdates := true;

tbMaster.Append;
tbDetail.Append;

tbMaster.FieldByName('ID').AsString := Edit1.Text;
tbMaster.FieldByName('MASTER_INFO').AsString := 'master' + Edit1.Text;

tbDetail.FieldByName('MASTER_ID').AsString := Edit1.Text;
tbDetail.FieldByName('DETAIL_INFO').AsString := 'detail' + Edit1.Text;

tbMaster.ApplyUpdates;

tbMaster.CommitUpdates;
tbDetail.CommitUpdates;

tbMaster.CachedUpdates := false;
tbDetail.CachedUpdates := false;
end;

When i do this with the older versions, the tbDetails data are posted to the Database too.

I build the same application with the newer versions and there it is necessary to do a tbDetails.Post, otherwise these data will not be posted to the database.

Does someone have an idea, please?

Greetings, Nils.

Is your master-detail setup by query Parameters in the detail query?
ex: SQL property of tldetail: select * from detail where idMaster = :idMaster

if it so Try to include fiDetails int the FetchOptions.Cache of tbDetail and tbMaster.
and set DetailCascade to true in tblMaster

If your datastes are binded to a GUI component like a GRID, this can lead to refresh the records when tbMaster.applyUpdates is executed

Check this documentation: http://docwiki.embarcadero.com/RADStudio/Tokyo/en/Master-Detail_Relationship_(M/D)
And also try to use centralized Cached Updates: http://docwiki.embarcadero.com/RADStudio/Tokyo/en/Caching_Updates_(FireDAC)#Centralized_Cached_Updates

Maybe some options now are by default activated or diabled an that is causing the issues you have. But is very simple to fix.

Edited by: Francisco Armando Dueñas Rodriguez on Apr 18, 2018 11:39 AM

Legend
Helpful Answer (5 pts)
Correct Answer (10 pts)

Server Response from: ETNAJIVE02