---
title: "DB2 Rowset to Fetch Multi-rows Easily"
description: "WITH ROWSET POSITIONING specifies that the cursor can be used with either row-positioned or rowset-positioned FETCH statements. This cursor can be used to return either a single row or multiple rows, as a rowset, with a single FETCH statement"
url: https://srinimf.com/2010/10/16/db2-we-can-fetch-multi-rows-with-cursor/
date: 2010-10-16
modified: 2026-10-10
author: "Srini"
image: https://i0.wp.com/srinimf.com/wp-content/uploads/2010/10/pexels-photo-3183164.jpeg?fit=1880%2C1253&ssl=1
categories: ["DB2"]
tags: ["Multi row fetch in DB2", "SQL tips and tricks"]
type: post
lang: en
---

# DB2 Rowset to Fetch Multi-rows Easily

The below sql with Row set postioning works to get for multi row fetching.

Related[DB2 Tough Questions (3 of 4)](https://srinimf.com/2012/02/01/db2-tough-questions-3-of-4/)

```
Exec sql
Declare cursor c1 with rowset positioning
for select a,b
from dsn8011.emp
where a > 1000
Fetch Rowset from c1
for 5 rows
into :host-var-arry;
End-sql
```

Related[DB2 Rowset to Fetch Multi-rows Easily](https://srinimf.com/2010/10/16/db2-we-can-fetch-multi-rows-with-cursor/)

Here **host-var-arry, **can handle data of 5 rows.

Related[Top Rowset Positioning Examples for INSERT, UPDATE and DELETE](https://srinimf.com/2016/01/25/db2-in-cursor-with-multi-record-fetching/)

### 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%2F10%2F16%2Fdb2-we-can-fetch-multi-rows-with-cursor%2F&media=https%3A%2F%2Fi0.wp.com%2Fsrinimf.com%2Fwp-content%2Fuploads%2F2010%2F10%2Fpexels-photo-3183164.jpeg%3Ffit%3D1200%252C800%26ssl%3D1&description=DB2%20Rowset%20to%20Fetch%20Multi-rows%20Easily)
-
- [Share on Tumblr](https://www.tumblr.com/share)
- [Share on WhatsApp (Opens in new window) WhatsApp](https://srinimf.com/2010/10/16/db2-we-can-fetch-multi-rows-with-cursor/?share=jetpack-whatsapp)
- [More](#)
-

- [Print (Opens in new window) Print](https://srinimf.com/2010/10/16/db2-we-can-fetch-multi-rows-with-cursor/?share=print)
- [Share on Reddit (Opens in new window) Reddit](https://srinimf.com/2010/10/16/db2-we-can-fetch-multi-rows-with-cursor/?share=reddit)
- [Share on Telegram (Opens in new window) Telegram](https://srinimf.com/2010/10/16/db2-we-can-fetch-multi-rows-with-cursor/?share=telegram)
- [Email a link to a friend (Opens in new window) Email](mailto:?subject=%5BShared%20Post%5D%20DB2%20Rowset%20to%20Fetch%20Multi-rows%20Easily&body=https%3A%2F%2Fsrinimf.com%2F2010%2F10%2F16%2Fdb2-we-can-fetch-multi-rows-with-cursor%2F&share=email)
-

### Like this:

Like Loading…
