VMS Help  —  RDML72  Statements  ROLLBACK
    Terminates a transaction and undoes all changes made to the
    database since the program's most recent START_TRANSACTION
    statement or since the start of the specified transaction.

1  –  Examples

    The following programs demonstrate the use of the ROLLBACK
    statement with a transaction handle to undo changes to the
    database made with the STORE statement. These programs:

    o  Start a READ_WRITE transaction, SAL_INCREASE

    o  Store a new JOBS record using the SAL_INCREASE transaction

    o  Use the ROLLBACK statement to undo the changes made to the
       database during the SAL_INCREASE increase transaction, that
       is, the new record is not stored in the database

    Note that the C program uses the pad_string function to read
    in the values for the STORE statement. This function pads the
    values stored in each field with the correct number of trailing
    blanks to ensure that the length of the values stored match the
    text size of the field. For more information on pad_string, see
    Appendix B of the "RDML Reference Manual".

1.1  –  C Example

    #include <stdio.h>
    DATABASE PERS = FILENAME "PERSONNEL";

    extern void pad_string();

    main()
    {
    int SAL_INCREASE = 0;

    READY PERS;
    START_TRANSACTION (TRANSACTION_HANDLE SAL_INCREASE) READ_WRITE;

    STORE (TRANSACTION_HANDLE SAL_INCREASE) J IN JOBS USING
       pad_string ("TYPS", J.JOB_CODE, sizeof(J.JOB_CODE));
       pad_string ("1", J.WAGE_CLASS, sizeof(J.WAGE_CLASS));
       pad_string ("TYPIST", J.JOB_TITLE, sizeof(J.JOB_TITLE));
       J.MINIMUM_SALARY = 10000;
       J.MAXIMUM_SALARY = 17000;
    END_STORE;

    ROLLBACK (TRANSACTION_HANDLE SAL_INCREASE);
    FINISH;
    }

1.2  –  Pascal Example

    program rollback_trans (input,output);
    DATABASE PERS = FILENAME 'PERSONNEL';
    var sal_increase : [volatile] integer := 0;

    begin
    READY PERS;
    START_TRANSACTION (TRANSACTION_HANDLE SAL_INCREASE) READ_WRITE;

    STORE (TRANSACTION_HANDLE SAL_INCREASE) J IN JOBS USING
        J.JOB_CODE := 'TYPS';
        J.WAGE_CLASS := '1';
        J.JOB_TITLE := 'Typist';
        J.MINIMUM_SALARY := 10000;
        J.MAXIMUM_SALARY := 17000;
    END_STORE;

    ROLLBACK (TRANSACTION_HANDLE SAL_INCREASE);
    FINISH;
    end.

2  –  Format

  (B)0ROLLBACK qqwqq>qqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqwqk
             mqq> ( qq> TRANSACTION_HANDLE qq> var qq> )qj x
                                                           x
             lqqqqqqqqqqqqqqqqqqqq<qqqqqqqqqqqqqqqqqqqqqqqqj
             x
             mqqqqqqqqwqqqqqqqqqqqqqqqqwqqqqqqqqqqqqqqqqqqqqq>
                      mq> on-error qqqqj

2.1  –  Format arguments

    TRANSACTION_HANDLE     The TRANSACTION_HANDLE keyword followed by
    var                    a host language variable. A transaction
                           handle identifies a transaction. If
                           you do not supply a transaction handle
                           explicitly, RDML uses the default
                           transaction handle.

    on-error               The ON ERROR clause. Specifies host
                           language statement(s) to be performed
                           if an error occurs during the ROLLBACK
                           operation. For more information see the
                           entry on ON ERROR.
Close Help