How to Understand COMMIT Process in DB2

Here is a topic that shows will cursors close or not when you have cursors logic in the COBOL DB2 program and you issue COMMIT.

Cursors after Commit

  • On COMMIT cursors will be closed automatically

A transaction is an atomic unit of work. This means that all statements within the transaction must succeed or none of them can have any effect.

  • What happens when one statement fails in series of SQL statements

If some statements within a transaction are executed and then one statement fails, all executed statements are rolled back and the database remains unchanged.

Life Cycle of Cursor

Cursor Life cycle
Cursor Life cycle

Commit in SQL

WITH HOLD and WITHOUT HOLD.

  • If you specify WITH HOLD, your cursor will remain open after you commit the transaction, until you explicitly close it.
  • If you specify WITHOUT HOLD, your cursor will be automatically closed when the transaction is committed.
  • If neither option is specified, WITHOUT HOLD is assumed and your cursor is automatically closed.

Read More

Author: Srini

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