For example, the process of adding an order described previously is a single transaction. If an error occurs, you only want to roll back to the point before theorders row was added. You do not want to roll back the addition to the customerstable (if there was one).
To support the rollback of partial transactions, you must be able to put placeholders at strategic locations in the transaction block. Then, if a rollback is required, you can roll back to one of the placeholders.
- These placeholders are called savepoints, and to create one use the SAVEPOINTstatement, as follows:
- • Input
Each savepoint takes a unique name that identifies it so that, when you roll back, MySQL knows where you are rolling back to. To roll back to this savepoint, do the following:
ROLLBACK TO delete1;