SQL Commit Vs Rollback: Syntax to Write in COBOL

COMMIT statement ends the logical unit of work.

Commit in SQL

EXEC SQL
COMMIT WORK
END-EXEC
  • The COMMIT will close all the locks that are acquired, except the cursors used with CURSOR WITH HOLD
  • COMMIT we should not use in stored procedures

ROLLBACK in SQL

EXEC SQL
ROLLBACK WORK
END-EXEC
  • It rolls back all the changes made to its last Save Point
  • In DB2, when abend occurs DB2 will do all the changes ROLLBACK implicitly
  • Ends logical unit of work
  • Cursors open with WITH HOLD will not be closed in IMS/CICS-when no work is performed since last commit point

Author: Srini

Experienced software developer. Skills in Development, Coding, Testing and Debugging. Good Data analytic skills (Data Warehousing and BI). Also skills in Mainframe.