COMMIT (terminate successful transaction)

Top  Previous  Next

 

COMMIT

The COMMIT statement terminates an active transaction. Execution of a COMMIT statement assumes that the transaction was completely successful and no ROLLBACK is necessary. Once COMMIT has been executed, ROLLBACK of the transaction is impossible.

COMMIT informs the file driver involved in the transaction that the temporary files containing the information necessary to restore the database to its previous state may be deleted. The file driver then performs the actions necessary to its file system to successfully terminate a transaction.

Errors Posted:

48

Unable to Log 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

Err" = ERROR()                     !Save the error message

ROLLBACK                           !Rollback the aborted transaction

ASSERT(~ERRORCODE())

BEEP                               !Alert the user

MESSAGE('Transaction Error - ' & Err")

RETURN                             !and get out

 

See Also:

LOGOUT

ROLLBACK