---
title: "Cursors Static Vs Scrollable – And its Top Uses in DB2"
description: "Simple Guidance For You In Db2 scrollable Cursors. Read more with examples."
url: https://srinimf.com/2010/08/19/db2-scrollabe-cursor/
date: 2010-08-19
modified: 2026-10-05
author: "Srini"
image: https://i0.wp.com/srinimf.com/wp-content/uploads/2010/08/pexels-photo-5710029.jpeg?fit=1880%2C1255&ssl=1
categories: ["DB2"]
tags: ["DB2 Tips and Solutions", "Scrollable Cursors"]
type: post
lang: en
---

# Cursors Static Vs Scrollable – And its Top Uses in DB2

**Scroll-able cursor** is a new topic. From DB2 Version 7, the concept of Scrollable cursor available.  Usually, after getting query result into Temporary table, developers apply this cursor to validate data.

**Note-**where as in static cursor you cannot search the resultant table back and forth. This is just sequential search.

```
DECLARE GLOBAL TEMPORARAY TABLE TEMP_PROJ
LIKE DSN8810.PROJ
INCLUDING IDENTITY
ON COMMIT PRESERVE ROWS; 
```

So the  mechanism of scrollable cursor works in temporary table. It will be stored in SYSIBM.SYSTABLES. These are not persistent , locking, logging and recovery do not apply.

> Indexes can not created. Constraints can not created. Can not be referenced by Utilities. When delete we need to delete all the rows.

**Some of the available options:**

- NEXT – will FETCH the next row, the same way that the pre-V7
- FETCH statement functioned
- PRIOR – will FETCH the previous row
- FIRST – will FETCH the first row in the results set
- LAST – will FETCH the last row in the results set
- CURRENT – will re-FETCH the current row from the [result set](https://srinimf.com/2016/10/24/how-to-know-the-cursor-type-is-associate-in-db2/)
- BEFORE – positions the cursor before the first row of the results set
- AFTER – positions the cursor after the last row of the results set
- ABSOLUTE n – will FETCH the row that is n rows away from the first row in the results set
- RELATIVE n – will FETCH the row that is n rows away from the last row fetched

**Example:**

```
DECLARE csr1 SENSITIVE STATIC 
SCROLL CURSOR FOR  
SELECT FIRSTNAME, LASTNME  
FROM DSN8710.EMP ORDER BY LASTNME F
ETCH FIRST 1000 ROWS ONLY;  OPEN csr1; 
FETCH ABSOLUTE 200 csr1 INTO :FN, :LN;
```

If I want to fetch rows between 200 and 500

```
FETCH 200 ROW
FETCH NEXT 300 TIMES
```

Basically, scrollable cursors reduce the amount of time and effort required to move backward and forward through the results of SQL queries.

**Recent posts**

- [How to Find Databricks Job Status, Owner, and Active Runs Fast](https://srinimf.com/2026/10/17/databricks-find-job-status/)
- [30 SQL Practice Queries with Solutions — Run Them Live](https://srinimf.com/2026/10/01/30-sql-practice-queries-with-solutions-run-them-live/)
- [Supercharge Your Database Skills: Try Our New Interactive SQL Plugin!](https://srinimf.com/2026/09/30/supercharge-your-database-skills-try-our-new-interactive-sql-plugin/)
- [How to Count Spark Stages by Sight and Optimize Shuffles](https://srinimf.com/2026/09/27/how-to-count-spark-stages-by-sight-and-optimize-shuffles/)
- [Databricks Cluster Min & Max: How to Find and Right-Size](https://srinimf.com/2026/09/19/databricks-cluster-min-max-how-to-find-and-right-size/)

### 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%2F2010%2F08%2F19%2Fdb2-scrollabe-cursor%2F&media=https%3A%2F%2Fi0.wp.com%2Fsrinimf.com%2Fwp-content%2Fuploads%2F2010%2F08%2Fpexels-photo-5710029.jpeg%3Ffit%3D1200%252C801%26ssl%3D1&description=Cursors%20Static%20Vs%20Scrollable%20-%20And%20its%20Top%20Uses%20in%20DB2)
-
- [Share on Tumblr](https://www.tumblr.com/share)
- [Share on WhatsApp (Opens in new window) WhatsApp](https://srinimf.com/2010/08/19/db2-scrollabe-cursor/?share=jetpack-whatsapp)
- [More](#)
-

- [Print (Opens in new window) Print](https://srinimf.com/2010/08/19/db2-scrollabe-cursor/?share=print)
- [Share on Reddit (Opens in new window) Reddit](https://srinimf.com/2010/08/19/db2-scrollabe-cursor/?share=reddit)
- [Share on Telegram (Opens in new window) Telegram](https://srinimf.com/2010/08/19/db2-scrollabe-cursor/?share=telegram)
- [Email a link to a friend (Opens in new window) Email](mailto:?subject=%5BShared%20Post%5D%20Cursors%20Static%20Vs%20Scrollable%20-%20And%20its%20Top%20Uses%20in%20DB2&body=https%3A%2F%2Fsrinimf.com%2F2010%2F08%2F19%2Fdb2-scrollabe-cursor%2F&share=email)
-

### Like this:

Like Loading…
