Cached master-detail and insertions

Discussion of open issues, suggestions and bugs regarding SDAC (SQL Server Data Access Components) for Delphi, C++Builder, Lazarus (and FPC)
Post Reply
Lithium™
Posts: 42
Joined: Wed 23 Jun 2010 06:42

Cached master-detail and insertions

Post by Lithium™ » Wed 23 Jun 2010 13:40

Is there way to insert some records into master-dataset, then insert some records into detail-dataset for each master-record, then navigate and modify all inserted records, afterwards apply updates for both master and detail MSQueries? (I was understandable expressed?)

To reach desired effect I perform plenty of monotonous handmade for each pair of master-detail in my application. A huge problem could become solved if way exists.

Dimon
Devart Team
Posts: 2885
Joined: Mon 05 Mar 2007 16:32

Post by Dimon » Thu 24 Jun 2010 08:06

When establishing master-detail relationship the CachedUpdates property of detail dataset works properly only when TCustomDADataSet.Options.LocalMasterDetail is set to True.
You can find more detailed information about this in the SDAC help.

Lithium™
Posts: 42
Joined: Wed 23 Jun 2010 06:42

Post by Lithium™ » Thu 24 Jun 2010 12:49

Thank you for response. I try this option before post began and unfortunately desired effect is not reached.

I explain more detailed. Inserted but not applied master-records has a no values for fields, which values fixed on server side (identity fields, fields with defvalues and the like). I need to set the MasterFields property of a detail-dataset exactly for such fields. In result the master-field has NULL value for all insertions and can not be used for my needs.

Dimon
Devart Team
Posts: 2885
Joined: Mon 05 Mar 2007 16:32

Post by Dimon » Thu 24 Jun 2010 15:07

1. You should set the TCustomDADataSet.Options.LocalMasterDetail property to True before dataset opening.
2. If you use fields with default values, to solve the problem, you should set the TCustomMSDataSet.Options.DefaultValues property to True. But if you use identity fields for master/detail relationship, you can not use the CachedUpdates mode.

Lithium™
Posts: 42
Joined: Wed 23 Jun 2010 06:42

Post by Lithium™ » Fri 25 Jun 2010 08:25

Thanks, I has missed the TCustomMSDataSet.Options.DefaultValues property, this became useful in some cases.

It's highly comfortable to use identity fields for master-detail relationships (in my application) and keep all datasets in Cached mode. I tried to find any way to do it. TCustomMSDataSet does not give such possibility, I suspected in general that (it not complaint to Devart).
Not it is necessary to talk that the way indeed exists. As variant to generate and store internal value for such fields and relate details (on client side) by this value, after update this values must be replaced with real values.

Are you plan to add such functionality for SDAC in future conceptually?

Dimon
Devart Team
Posts: 2885
Joined: Mon 05 Mar 2007 16:32

Post by Dimon » Tue 29 Jun 2010 09:27

We don't plan to implement such functionality, because it is very specific. You can implement it yourself in your application.

Lithium™
Posts: 42
Joined: Wed 23 Jun 2010 06:42

Post by Lithium™ » Wed 30 Jun 2010 05:46

I can't argue about specificity (may be other forum visitors can say anything about :?: ), however thank you for argued answer.

Post Reply