Cached Updates and master detail relationship

Forum related to version 6.5.1 (alpha) and 6.6.x (beta) of ZeosLib's DBOs

Moderators: gto, cipto_kh, EgonHugeist

Post Reply
marcocot
Fresh Boarder
Fresh Boarder
Posts: 17
Joined: 23.05.2007, 13:52

Cached Updates and master detail relationship

Post by marcocot »

Hello!
I need to have one or more transaction firing together, but to have this
situation I shoud have more than one connection as there's no Transaction
component , but sometimes it can be very slow starting a new connection.For this reason I am trying my hand to the cached updates. It is simple when I need to update one table, but I have problems in master-detail relationship. I probably fail in doing something, but really can understand where.
I use autoincrement indexes so I don't know the master key until I apply updates. I use two TZQuery components , and try to set mastersource,masterkey and linkedfields, but seems not to work well, each time I apply master's updates, I loose all records in the detail ( master maybe refreshes the detail). The same thing happens if I join the two tables using datasource property and the WHERE ID = :ID in the select. How can I menage master detail and cached updates? Thanks for any advice.

Marco
bangfauzan
Senior Boarder
Senior Boarder
Posts: 50
Joined: 31.08.2006, 10:41
Contact:

Post by bangfauzan »

Detail dataset is automatically fill the key field with the value of master's key field. if master's key field is null (e.g. becouse the key field is autoincreament), the value of detail's key field also null.
Solution :
You first have to post (applyupdate) the master dataset (and get the key value) before you add new record on the detail dataset.

Regards.
Fauzan Badriawan
btrewern
Expert Boarder
Expert Boarder
Posts: 193
Joined: 06.10.2005, 18:51

Post by btrewern »

What database are you using? In PostgreSQL I look up the required id for the field

Code: Select all

SELECT nextval(seq_name);
and enter it into the dataset. It can then be posted to the database (ApplyUpdates) when needed or discarded if the user decides to cancel the transaction.

I hope this helps,

Regards,

Ben
Post Reply