---
title: "SQL Rollback: How to Understand Its Background Process"
description: "ROLLBACK and cursors there is a relation for these two things in DB2. This post tell all about cursors behavior when ROLLBACK happens."
url: https://srinimf.com/2011/09/18/db2-rollback-cursors/
date: 2011-09-18
modified: 2026-10-10
author: "Srini"
image: https://i0.wp.com/srinimf.com/wp-content/uploads/2011/09/pexels-photo-1005058.jpeg?fit=1880%2C1253&ssl=1
categories: ["DB2"]
tags: ["DB2 Cursors", "Db2 Tips"]
type: post
lang: en
---

# SQL Rollback: How to Understand Its Background Process

[In DB2](https://srinimf.com/2014/10/19/truncate-and-delete-in-db2/) or any database, Rollback initiates if any exception occurs. A Rollback automatically sets the data to the previous commit. Moreover, below you will find what happens to the cursors and locks.

## Rollback

Here is the process that triggers after the Rollback enacts in SQL.

The ROLLBACK causes:

- All open cursors are closed.
-  All locks acquired during the [unit of work](https://srinimf.com/2012/05/03/db2-commit-work-and-rollback-work/) are released.
-  Freed all LOB locators
- When you specify the “WITH HOLD” option in the [SELECT statement](https://srinimf.com/2014/07/09/4-traits-in-db2-cursor-with-hold/), the cursors will not be closed. It always puts the cursor at the next logical row. 
- Open cursors defined WITH HOLD remain open. 
- All locks are released, except locks protecting the current cursor position of open WITH HOLD cursors.
- After committing, if we define the “DISCONNECT” unless the cursor is explicitly closed, the DISCONNECT will be failed. It is needed once the cursor is closed to re-open it after ROLLBACK.

Related

- [SQL Commit Vs Rollback: Syntax to Write in COBOL](https://srinimf.com/2012/05/03/db2-commit-work-and-rollback-work/)DateMay 3, 2012
- [DB2: Cursor WITH HOLD, CLOSE, OPEN Ideas](https://srinimf.com/2015/07/07/db2-with-hold-close-and-open-of-cursors-in-commit-or-rollback/)DateJuly 7, 2015
- [Quick Tutorial on DB2 Cursors](https://srinimf.com/2015/02/24/5-new-things-on-db2-cursors/)DateFebruary 24, 2015

### Share this:

-
- [Tweet](https://twitter.com/share)
- [![](https://i0.wp.com/assets.pinterest.com/images/pidgets/pinit_fg_en_rect_gray_20.png)](https://www.pinterest.com/pin/create/link/?url=https%3A%2F%2Fsrinimf.com%2F2011%2F09%2F18%2Fdb2-rollback-cursors%2F&media=https%3A%2F%2Fi0.wp.com%2Fsrinimf.com%2Fwp-content%2Fuploads%2F2011%2F09%2Fpexels-photo-1005058.jpeg%3Ffit%3D1200%252C800%26ssl%3D1&description=SQL%20Rollback%3A%20How%20to%20Understand%20Its%20Background%20Process)
-
- [Share on Tumblr](https://www.tumblr.com/share)
- [Share on WhatsApp (Opens in new window) WhatsApp](https://srinimf.com/2011/09/18/db2-rollback-cursors/?share=jetpack-whatsapp)
- [More](#)
-

- [Print (Opens in new window) Print](https://srinimf.com/2011/09/18/db2-rollback-cursors/?share=print)
- [Share on Reddit (Opens in new window) Reddit](https://srinimf.com/2011/09/18/db2-rollback-cursors/?share=reddit)
- [Share on Telegram (Opens in new window) Telegram](https://srinimf.com/2011/09/18/db2-rollback-cursors/?share=telegram)
- [Email a link to a friend (Opens in new window) Email](mailto:?subject=%5BShared%20Post%5D%20SQL%20Rollback%3A%20How%20to%20Understand%20Its%20Background%20Process&body=https%3A%2F%2Fsrinimf.com%2F2011%2F09%2F18%2Fdb2-rollback-cursors%2F&share=email)
-

### Like this:

Like Loading…
