Using ROLLBACK and END TRANSACTION in Nested TransactionsLast reviewed: April 30, 1996Article ID: Q129647 |
The information in this article applies to:
SUMMARYVisual FoxPro allows transactions to be nested up to five levels deep. This article explains the results of using ROLLBACK and END TRANSACTION within nested transactions.
MORE INFORMATIONWhen you issue a BEGIN TRANSACTION command, the transaction level is incremented by one. When you issue an END TRANSACTION, changes to the same record are written starting at the first transaction level and ending with the fifth or last transaction level. When you issue a ROLLBACK, changes to the same record are discarded beginning with the highest (fifth or last) transaction level and ending with the first transaction level.
Code Sample OneTo test the behavior of nested transactions, follow these steps:
Code Sample TwoModify the program so that it reads as follows (the inner two END TRANSACTION commands have been changed to ROLLBACK commands). Rerun the program, and notice that the results are much different.
OPEN DATABASE nested USE test APPEND BLANK BEGIN TRANSACTION REPLACE cLevel WITH "One" =tranlevel("Begin transaction") BEGIN TRANSACTION REPLACE cLevel WITH "Two" =tranlevel("Begin transaction") BEGIN TRANSACTION REPLACE cLevel WITH "Three" =tranlevel("Begin transaction") ROLLBACK =tranlevel("Rollback") ROLLBACK =tranlevel("Rollback") END TRANSACTION =tranlevel("End transaction") * PROCEDURE tranlevel DOES NOT CHANGE *** END OF CODE EXAMPLEThe final value of the field cLevel should be "One."
|
Additional reference words: 3.00 VFoxWin
© 1998 Microsoft Corporation. All rights reserved. Terms of Use. |