Board index » delphi » One transaction for one master with one detail (D5E IBX52 Interbase6)

One transaction for one master with one detail (D5E IBX52 Interbase6)

Normally I develop my application in such a way that the user first
HAS TO create (and commit) the master record BEFORE he/she will be
allowed to work with (insert/edit/delete) the detail record. However
in thise case I tried to "cut a corner".

I have one form into which I present ONE master record. The controls
are all DBaware so as soon as you change anything the DataSource's
state is automatic changeing into "Edit mode". On the form I have a
"Ok" and a "Cancel" button. Clicking the canel button will cancel
RollBack and Clicking OK will Post the changes and then Commit the
transaction (this is all fine).

However my problem is my detail. Whenever I try to work with the
detail any un-commited changes to the master is removed (it looks like
the master is refreshed, even though I can not verify this). In other
words the chagnes you might have made to the master is automatic
un-done and you will see the master data as they appeared when you
entered the form.

I have tried "splitting" the "master" and the "detail" so that the
detail DataSource does NOT "point" to the master-record (in stead I in
the details SelectSQL I make sure only to read the data that "belongs
to" that "master"). Also I have tried making a separat transaction for
the detail however the result is the same.

I use TIBDataSet both for the "master" and the "detail" and their
selectSQL looks like this:

Master
<SNIP>
select CASEID, CASEPARTID, CASESUBJECT, CASEDESCRIPTION, KEYWORDS,
FAQ_PUBLIC, CASEPRIORITY, EST_DEADLINE, REAL_DEADLINE, CASEWORKFLOW,
CASESOLUTION, CASESTATUS, CASEREVISION, RESPONSABLE, CREATED_BY,
CREATED_AT, CHANGED_BY, CHANGED_AT
from CASEPARTS
where (CASEID = :CASEID)
and (CASEPARTID = :CASEPARTID)
</SNIP>

"Detail"
<SNIP>
select CASEID, CASEPARTID, ACCOUNTID, USERID, REPORTED_AT,
RESOURCE_USAGE, MEMO
from CASERESOURCEUSAGE
where (CASEID = :CASEID)
and (CASEPARTID = :CASEPARTID)
</SNIP>

 

Re:One transaction for one master with one detail (D5E IBX52 Interbase6)


Why are the "easiest" problems always those you spend the most time on
?. The problem was very easy to fix. All I had to do was to post the
changes to my master-record BEFORE i changed the state of the
DataSource connected to the detail (done within the OnStateChange for
the detail).

The post is still "within" the transaction so that I can still use
"OK" to commit the changes or "Cancel" to Roll them back.

On Fri, 25 May 2001 11:41:56 +0200, Pelle F. S. Liljendal <p...@bodi.dk>
wrote:

Quote
>...
>I have one form into which I present ONE master record. The controls
>are all DBaware so as soon as you change anything the DataSource's
>state is automatic changeing into "Edit mode". On the form I have a
>"Ok" and a "Cancel" button. Clicking the canel button will cancel
>RollBack and Clicking OK will Post the changes and then Commit the
>transaction (this is all fine).

>However my problem is my detail. Whenever I try to work with the
>detail any un-commited changes to the master is removed (it looks like
>the master is refreshed, even though I can not verify this). In other
>words the chagnes you might have made to the master is automatic
>un-done and you will see the master data as they appeared when you
>entered the form.
>...

Other Threads