Page 1 of 1

Cached Updates and master detail relationship

Posted: 07.06.2007, 17:06
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

Posted: 11.06.2007, 01:58
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

Posted: 11.06.2007, 11:17
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