Page 1 of 1

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

Posted: 27.08.2013, 14:34
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;

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

Posted: 29.08.2013, 08:28
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