SQL/MX Quick Start (G06.24+, H06.03+)
Protecting Database Integrity
HP NonStop SQL/MX Quick Start—523724-002
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 have 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 roll back all changes made since you entered BEGIN WORK by entering the
ROLLBACK WORK statement:
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, 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, 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.