RDB/VMS Relational Database Operator ROLLBACK — VMS RDB_3.1A
Terminates a transaction and undoes all changes that have been made
to the database since the program's most recent START_TRANSACTION
statement. The ROLLBACK statement also closes all open streams and
releases all locks. The ROLLBACK statement affects both data
manipulation and data definition statements.
Example:
RDO> START_TRANSACTION READ_WRITE
RDO> DEFINE FIELD LOCATION_CODE DATATYPE TEXT SIZE 5.
RDO> ! Oops, wrong size!
RDO> ROLLBACK
RDO> START_TRANSACTION READ_WRITE
RDO> DEFINE FIELD LOCATION_CODE DATATYPE TEXT SIZE 7.
RDO> COMMIT
Additional information available:
Format
ROLLBACK ──┬───────────────────────>──────────┬─┬────────────────┬───> └─> (
T
R
A
N
S
A
C
T
I
O
N
H
A
N
D
L
E ──> var) ──┘ └──> on-error ───┘
Additional information available:
TRANSACTION_HANDLE
A keyword followed by a host language variable. A transaction handle identifies each instance of a database attach. If you do not declare the transaction handle explicitly, Rdb/VMS attaches an internal identifier to the transaction. In Callable RDO, use !VAL as a marker for host language variables. You can put parentheses around the host language variable name. Normally, you do not need to use this argument. The ability to declare a transaction handle is provided for compatibility with other database products and future releases of Rdb/VMS.
on-error
The ON ERROR clause, which specifies a host language statement to be performed if an Rdb/VMS error occurs. For more details, request HELP on ON_ERROR.
Example
Roll back changes made during a transaction with a COBOL program:
GET-ID-NUMBER.
DISPLAY "Enter employee ID number: "
WITH NO ADVANCING.
ACCEPT EMPLOYEE-ID.
CHANGE-SALARY.
DISPLAY "Enter new salary amount: "
WITH NO ADVANCING.
ACCEPT SALARY-AMOUNT.
&RDB& START_TRANSACTION READ_WRITE
&RDB& FOR S IN SALARY_HISTORY WITH
&RDB& E.EMPLOYEE-ID = EMPLOYEE-ID
&RDB& MODIFY USING
&RDB& S.SALARY-AMOUNT = SALARY-AMOUNT
&RDB& END-MODIFY
&RDB& END-FOR
DISPLAY EMPLOYEE-ID, SALARY-AMOUNT.
DISPLAY "Is this figure correct? [Y or N] "
WITH NO ADVANCING.
ACCEPT ANSWER.
IF ANSWER = "Y" THEN
&RDB& COMMIT
ELSE
&RDB& ROLLBACK
DISPLAY "Please enter the new salary amount again."
GO TO CHANGE-SALARY.