Master Detail with CachedUpdate

Discussion of open issues, suggestions and bugs regarding PgDAC (PostgreSQL Data Access Components) for Delphi, C++Builder, Lazarus (and FPC)
AlexP
Devart Team
Posts: 5530
Joined: Tue 10 Aug 2010 11:35

Post by AlexP » Wed 25 Apr 2012 09:15

Hello,

For a master table, the SequenceMode must be set to smInsert for correct master-detail data relation; for a detail table, you can use any value of SequenceMode, depending on the needed behaviour

lauchuen
Posts: 37
Joined: Fri 07 Aug 2009 16:59

Post by lauchuen » Wed 25 Apr 2012 09:25

but, does smInsert work on Offline mode ?

AlexP
Devart Team
Posts: 5530
Joined: Tue 10 Aug 2010 11:35

Post by AlexP » Wed 25 Apr 2012 10:11

Hello,

When using the Disconnected mode with enabled smlinsert, the server will be connected and the query for retrieving the sequence value will be sent automatically. After that, it will disconnect.

lauchuen
Posts: 37
Joined: Fri 07 Aug 2009 16:59

Post by lauchuen » Wed 25 Apr 2012 10:21

oic, i got it. but any draw back/disadvantage by using disconnected mode ?

AlexP
Devart Team
Posts: 5530
Joined: Tue 10 Aug 2010 11:35

Post by AlexP » Wed 25 Apr 2012 11:32

Hello,

The Disconnected mode is recommended to minimize data loss for networks with unstable/bad connection, where there are a lot of disconnections. In this mode, the connection is set only when data needs to be sent/received between a server and a client, therefore some performance loss is possible, as to perform each operation, a new connection is needed.

lauchuen
Posts: 37
Joined: Fri 07 Aug 2009 16:59

Post by lauchuen » Thu 26 Apr 2012 10:22

icic, thanks.

one more question, if the connection already establish (in good network environment), when performing operation, will it re-connect to server again ?

AlexP
Devart Team
Posts: 5530
Joined: Tue 10 Aug 2010 11:35

Post by AlexP » Thu 26 Apr 2012 12:59

hello,

If you work with a stable connection, you don't need to use the Disconnected mode. The main specificity of the Disconnected mode is that you don't need to open connection explicitly, i.e. you don't need to call the PgConnection.Connect method, the connection will be set on demand. If you connect to the server explicitly in the disconnect mode, than it will work in the usual mode without automatic server connection/disconnection.

lauchuen
Posts: 37
Joined: Fri 07 Aug 2009 16:59

Re: Master Detail with CachedUpdate

Post by lauchuen » Wed 30 May 2012 15:28

hello,

its me again...now, i've another table schema which similar to previous.

Code: Select all

master table (
 id varchar(50) primary key,
 name varchar(50) NOT NULL,
);

detail table (
 id serial primary key,
 master_id varchar(50) NOT NULL,
 name varchar(50) NOT NULL
);
just the serial id field changed to varchar(50) and name now is not null. i found that master table must be posted before detail table insert record, is that true ? how to avoid that ?

following my settings:
tblMaster.SQL.Text := 'SELECT * FROM master';
tblMaster.CachedUpdates := True;
tblMaster.Options.DefaultValues := True;
tblMaster.Options.LocalMasterDetail := True;

tblDetails.SQL.Text := 'SELECT * FROM detail';
tblDetails.CachedUpdates := True;
tblDetails.Options.DefaultValues := True;
tblMaster.Options.LocalMasterDetail := True;

since name field now is not null, the users may insert detail record before fill the name field (since i can't control the users behavior), so any solution about this ? very urgent, please help.

AlexP
Devart Team
Posts: 5530
Joined: Tue 10 Aug 2010 11:35

Re: Master Detail with CachedUpdate

Post by AlexP » Thu 31 May 2012 11:47

Hello,

For MasterDataSet it is necessary to use the smInsert mode, for DetailDataSet - any of modes, but to decrease server calls number and avoid counter increasing, it is better to use the smPost mode.

lauchuen
Posts: 37
Joined: Fri 07 Aug 2009 16:59

Re: Master Detail with CachedUpdate

Post by lauchuen » Thu 31 May 2012 11:55

already use smInsert for MasterDataSet, but if i haven't Post the MasterDataSet before insert DetailDataSet record, after i Post the MasterDataSet, all DetailDataSet has gone (disappear).

and this only appear when the table was empty (no record), bugs?

AlexP
Devart Team
Posts: 5530
Joined: Tue 10 Aug 2010 11:35

Re: Master Detail with CachedUpdate

Post by AlexP » Tue 05 Jun 2012 11:18

hello,

When realizing the Master-Detail relation, with any values of the CachedUpdates and LocalMasterDetail options, the Post method should be called for a master record before the detail records correspondent to it are added. But when enabling these options, the Post method will insert data only to the local DataSet without saving them to the server.

lauchuen
Posts: 37
Joined: Fri 07 Aug 2009 16:59

Re: Master Detail with CachedUpdate

Post by lauchuen » Sat 30 Jun 2012 14:52

hi,

does the latest version have any update related to this features ?

AlexP
Devart Team
Posts: 5530
Joined: Tue 10 Aug 2010 11:35

Re: Master Detail with CachedUpdate

Post by AlexP » Mon 02 Jul 2012 06:56

hello,

We are still working on this problem.
We will notify you as soon as we have any results.

lauchuen
Posts: 37
Joined: Fri 07 Aug 2009 16:59

Re: Master Detail with CachedUpdate

Post by lauchuen » Mon 02 Jul 2012 19:45

thank you for the effort. since i think it is very important for database application development on the master-detail relationship. refer to the database side, there're also has a foreign key to control cascade or restrict update/delete. and i think there're also not every application use un-changeable ID for their application, hopeful your team can fix this problem soon.

Post Reply