| **Navigation:**  [[introduction.htm|Language Reference]] > 13 - Built-in Functions >====== ROLLBACK (terminate unsuccessful transaction) ====== | [[right return right justified string .htm|{{btn_prev_n.gif|Previous page}}]][[introduction.htm|{{btn_home_n.gif|Return to chapter overview}}]][[round return rounded number .htm|{{btn_next_n.gif|Next page}}]] | | || **ROLLBACK** {{blk2blue.jpg|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 begin transaction .htm|LOGOUT]] [[commit terminate successful transaction .htm|COMMIT]]