|
When altering multiple related database records, it's important that all transactions proceed.
Attributes
Normally database operations take place immediately when a database tag is executed. Use <MvTRANSACT> to begin a new transaction when you want to save or cancel a series of changes made to data sources as a single unit. For example, to transfer money between accounts, you subtract an amount from one and add the same amount to the other. If either update fails, the accounts no longer balance. Making these changes within an open transaction ensures that either all or none of the changes go through. If any errors are encountered, use <MvROLLBACK> to cancel all the changes. ExampleIn this example, if a delete functions fail the transaction is rolled back using <MvROLLBACK> to the previous state. Example:<MvTRANSACT NAME = "Merchant"> <MvIF EXPR = "{ NOT CategoryXProduct_Delete_All_Product( l.product:id ) }"> <MvROLLBACK NAME = "Merchant"> <MvFUNCTIONRETURN VALUE = 0> </MvIF> |