You have read quite a bit about how database transactions are backed out and how database changes are undone. But what happens to work done with variables?
Any changes made to variables in a database transaction or subtransaction block are undone whenever a database transaction or subtransaction is backed out. The variables are restored to the values they had at the beginning of the transaction or subtransaction that is undone. Variables specifically defined as NO-UNDO are not undone in this case. However, changes to variables made outside a database transaction are never undone since only transaction and subtransaction blocks can be undone.
Although backing out of variables is useful in many cases, there is a certain amount of overhead associated with undoing variables in database transactions. If you are doing extensive calculations and have no need for undo services, then consider using the NO-UNDO option on variables and arrays.