SQL/MX Quick Start (H06.04+, J06.03+)

Protecting Database Integrity
HP NonStop SQL/MX Quick Start540438-001
8-2
Ending a Transaction
Ending a Transaction
If a problem occurs during the transaction, you can roll back, or undo, the transaction
to cancel the changes you made up to that point. If no problems occur, you can commit
the changes to the database.
Example
Suppose you realize that you did not want prices between $1000 and $2000 doubled.
You can enter the ROLLBACK WORK statement to roll back all changes since you
entered BEGIN WORK:
ROLLBACK WORK;
--- SQL operation complete.
The database values are the same as they were before you entered the UPDATE
statement.
Example
Now you can start another transaction and enter the correct version of the UPDATE
statement. When you know the changes are correct, enter the COMMIT WORK
statement to complete the transaction:
COMMIT WORK;
--- SQL operation complete.
Tip
By default, NonStop SQL/MX automatically defines a transaction for SELECT,
DELETE, UPDATE, and INSERT statements that you enter. This default protects
the database if system failure or some other system problem occurs. If no
problems occur, NonStop SQL/MX commits the changes to the database, and you
cannot roll back the changes.
Only audited tables are protected by transactions. By default, tables are audited,
and you can protect your transactions on tables by using BEGIN WORK, COMMIT
WORK, and ROLLBACK WORK.