how to persist master-detail tables in a single transaction?

Forum related to MySQL

Moderators: gto, cipto_kh, EgonHugeist

Post Reply
lsrzj
Fresh Boarder
Fresh Boarder
Posts: 19
Joined: 26.07.2013, 16:30

how to persist master-detail tables in a single transaction?

Post by lsrzj »

Hello,

I'm trying to get the next insertion ID of the master table to put it to the detail's MasterFK field and persist both of the tables in one single commit. How can I accomplish this?

What I tried to do is something like

ZConnection options:
AutoCommit = FALSE
TransactionIsolationLevel = tiReadCommitted

ZQuery options:
CachedUpdates = TRUE

ZQuery1Field1.Value := Edit1.Text;
ZQuery1.ApplyUpdates;
ZQuery2MasterFK.Value := ZQuery1Id.Value;
ZQuery2Field1.Value := Edit2.Text;
ZQuery2.ApplyUpdates;
ZConnection1.Commit;
User avatar
mdaems
Zeos Project Manager
Zeos Project Manager
Posts: 2766
Joined: 20.09.2005, 15:28
Location: Brussels, Belgium
Contact:

Re: how to persist master-detail tables in a single transact

Post by mdaems »

This is a good question. But I don't know the solution.
When using mysql autoincrements are retrieved at post time. So I think you should at least make sure posting happens immediately when doing record navigation.

For databases where the ZSequence component is implemented it may be easier to assign the id's using the ZSequence component.

Mark
Image
Post Reply