User Tools

Site Tools


rollback_terminate_unsuccessful_transaction_.htm
Navigation:  Language Reference > 13 - Built-in Functions >====== ROLLBACK (terminate unsuccessful transaction) ====== Previous pageReturn to chapter overviewNext page

ROLLBACK

blk2blue.jpg

The ROLLBACK statement terminates an active transaction. Execution of a ROLLBACK statement assumes that the transaction was unsuccessful and the database must be restored to the state it was in before the transaction began.

ROLLBACK informs the file driver involved in the transaction that the temporary files containing the information necessary to restore the database to its previous state must be used to restore the database. The file driver then performs the actions necessary to its file system to roll back the transaction.

Errors Posted:

65 Unable to ROLLBACK Transaction
91 No Logout Active

Example:

LOGOUT(1,OrderHeader,OrderDetail)     !Begin Transaction

DO ErrHandler                         !always check for errors

ADD(OrderHeader)                      !Add Parent record

DO ErrHandler                         !always check for errors

LOOP X# = 1 TO RECORDS(DetailQue)     !Process stored detail records

 GET(DetailQue,X#)                    !Get one from the QUEUE

 DO ErrHandler                        !always check for errors

 Det:Record = DetailQue               !Assign to record buffer

 ADD(OrderDetail)                     !and add it to the file

 DO ErrHandler                        !always check for errors

END

COMMIT                                !Terminate successful transaction

ASSERT(~ERRORCODE())

ErrHandler ROUTINE                     !Error routine

IF NOT ERRORCODE() THEN EXIT.         !Bail out if no error

ROLLBACK                              !Rollback the aborted transaction

ASSERT(~ERRORCODE())

BEEP                                  !Alert the user

MESSAGE('Transaction Error - ' & ERROR())

RETURN                                !and get out

See Also:

LOGOUT

COMMIT

rollback_terminate_unsuccessful_transaction_.htm.txt · Last modified: 2021/04/15 15:57 by 127.0.0.1