Forum > Databases

CachedUpdate

(1/3) > >>

Medhome:
Hi all,

I use cachedUpdate with master-slave schema . 
Do I have  to applyupdates-commit  current record (master and slave records )  before adding an other master record?

My problem is:

Adding the first master record  and it's slave records  it's Ok
But when I add a second master   the  slave records  disappear  from the grid.?

Did I miss an option?   

tonyw:
No. That's how it's meant to work. Change the master record and the slave table is cleared and reloaded referencing the new master record. You need  a beforescroll event handler in the master table that applies the cached updates in the slave before the master record changes.

Medhome:
You mean that we have to applyUpdates to  master and  slave before adding a new master record?

Med

tonyw:

--- Quote from: Medhome on July 03, 2021, 11:11:02 pm ---You mean that we have to applyUpdates to  master and  slave before adding a new master record?

Med

--- End quote ---
I would not used cached updates for a master dataset. It is far too easy to get out of sync and get unknown foreign key errors when the updates are applied to the slave.

Cached updates are simply deferred updates that have not yet been applied to a dataset. If you add a new master record but do not write it through to the database and then add records to the slave referencing the new master, you have a problem if the slave records are applied (written to the database) while the master record is stil cached in the client. From the point of view of the database, the records in the slave dataset are referencing a record in the master that does not yet exist.

Why are you using cached updates? Database transactions give you more control, especially in master/slave relationships. If you are using a database such as paradox or an old version of mysql then it is understandable, but if you are using a database with transaction control then I would recommend using transactions instead of cached updates.

korba812:

--- Quote from: tonyw on July 04, 2021, 12:02:43 am ---I would not used cached updates for a master dataset. It is far too easy to get out of sync and get unknown foreign key errors when the updates are applied to the slave.

--- End quote ---
There is nothing wrong with using CachedUpdates as long as you do it correctly. I am using Rollback transaction only in case of error while saving changes to database. I have been using this for years and am happy with it, even with Master-Detail. You just need to follow the order in which to commit changes to datasets.

Navigation

[0] Message Index

[#] Next page

Go to full version