Level Extreme platform
Subscription
Corporate profile
Products & Services
Support
Legal
Français
Nested Transaction
Message
General information
Forum:
Visual FoxPro
Category:
Coding, syntax & commands
Miscellaneous
Thread ID:
00090423
Message ID:
00090482
Views:
20
No. You will ROLLBACK only the innermost transaction. If you want to roll back everything when one delete transaction fails, you'll need to do another ROLLBACK. For example, in DeleteAll do something like this:

m.llRollback=.F.
BEGIN TRANSACTION
SCAN FOR OrderKey=m.OrderKey
IF !DeleteOne()
m.llRollBack=.T.
ROLLBACK
EXIT
ENDIF
ENDSCAN
IF !m.llRollBack
END TRANSACTION
ENDIF

This assumes that DeleteOne() returns .F. if it fails to carry out the deletion.

>I use a grid for the detail of an order entry form, I added methods to the grid rather than the form because the same grid is used on several forms. One method, I call DeleteOne, deletes the current record of the recordsource of the grid. I begin a transaction,make updates to three other tables effected by the delete, and if all is successfull, delete the record, if not ROLLBACK.
>
>Now I want to add a method that deletes all records in the grid which is detail for a single order. Call it DeleteAll and I want to begin a transaction, start at first record and call DeleteOne ( remeber this method uses BEGIN TRANS and END TRANS in itself ) and move through the detail records calling DeleteOne on each record. If for some reason one record can not be deleted and I issue ROLLBACK in DeleteAll method, will the tables updated when END TRANS was issued on each record in DeleteOne be rolled back also ?
Previous
Next
Reply
Map
View

Click here to load this message in the networking platform