Icon View Thread

The following is the text of the current message along with any replies.
Messages 1 to 5 of 5 total
Thread Transaction rollback question
Wed, Apr 26 2006 9:17 AMPermanent Link

Ahmet Mavi
Master-Detail (ORDER and ORD_DETAIL)

ORDER is insert state , details are in a memory table:
==================================

StartTransaction
try
  ORDER.Post;
  // code to Insert the records into the disk based detail table
  COMMIT;
except
  ROLLBACK;
end;

===================================

if the above transaction fails, nothing is inserted into detail table, which is fine. But I lost the current ORDER record, which
was in insert state before the transaction.

What is the best way for getting the ORDER record back into the insert state with the same values again, if the transaction
fails?

Ahmet


Wed, Apr 26 2006 10:21 AMPermanent Link

Tim Young [Elevate Software]

Elevate Software, Inc.

Avatar

Email timyoung@elevatesoft.com

Ahmet,

<< if the above transaction fails, nothing is inserted into detail table,
which is fine. But I lost the current ORDER record, which
was in insert state before the transaction.

What is the best way for getting the ORDER record back into the insert
state with the same values again, if the transaction fails? >>

Don't include it in the transaction by using a restricted transaction on
only the detail table:

http://www.elevatesoft.com/dbisam4d5_transactions.htm

--
Tim Young
Elevate Software
www.elevatesoft.com

Wed, Apr 26 2006 11:24 AMPermanent Link

Ahmet Mavi
<<Don't include it in the transaction by using a restricted transaction on
only the detail table:>>


ORDER.Post;
StartTransaction
try
 // code to Insert the records into the disk based detail table
 COMMIT;
except
 ROLLBACK;
end;

In this case, there is another problem if ORDER is posted to the database and transaction failed.

Ahmet
Wed, Apr 26 2006 1:18 PMPermanent Link

"Jose Eduardo Helminsky"
Ahmet

I've been using a solution that was not very easy to implement. I had
inherit a TDBISamDatabase and changed the StartTransaction, Commit and
RollBack method.

Just *after* the transaction starts, it saves (in memory) the current record
of tables in insert or edit mode and the record pointer from tables in
browse mode. If the commit occurs OK then the memory is freed but if it
fails I have a way to get my tables in a situation just before the
transaction. It takes care of Refresh ALL tables before back to this
situation.

IOW, it takes a picture *before* transaction and if it fails then a put the
initial picture back.

I have been using this since 4.15 and works like expected.

Eduardo

Thu, Apr 27 2006 10:52 AMPermanent Link

Tim Young [Elevate Software]

Elevate Software, Inc.

Avatar

Email timyoung@elevatesoft.com

Ahmet,

<< In this case, there is another problem if ORDER is posted to the database
and transaction failed. >>

Well, you either have the ORDER table in the transaction or you don't.
There is no in-between.  If you want to preserve the original ORDER record
after a rollback, then you need to save it in a temporary table and then
restore it manually after a rollback.

--
Tim Young
Elevate Software
www.elevatesoft.com

Image