471,086 Members | 848 Online
Bytes | Software Development & Data Engineering Community
Post +

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 471,086 software developers and data experts.

When to use cursors?

Hello,

I was trying to find the information about when and where should I use
cursors in DB2, no luck. Maybe you can point me to some article that
describes just that (or tell me which page is it in DB2 SQL reference
book, if it's there)? Or maybe you can post a short answer here, if
there's no dedicated article?

Another question would be about scrollable cursors (just found out
about their existence) - what performance gains will I get by using
them over the technique I'm using right now:

<code>SELECT T.* FROM
(SELECT FOO.*, ROWNUM() as ROWNUM
FROM (some query) AS FOO
) AS T
WHERE T.ROWNUM RMIN AND T.ROWNUM < RMAX</code>

I'm using PHP via ibm_db2 PECL module, but also plan to use Python
soon (most probably via PyDB2). Considering to use stored procedures.

Jun 28 '07 #1
1 6531
On Jun 28, 12:19 am, Dima Kuchin <kuc...@gmail.comwrote:
Hello,

I was trying to find the information about when and where should I use
cursors in DB2, no luck. Maybe you can point me to some article that
describes just that (or tell me which page is it in DB2 SQL reference
book, if it's there)? Or maybe you can post a short answer here, if
there's no dedicated article?

Another question would be about scrollable cursors (just found out
about their existence) - what performance gains will I get by using
them over the technique I'm using right now:

<code>SELECT T.* FROM
(SELECT FOO.*, ROWNUM() as ROWNUM
FROM (some query) AS FOO
) AS T
WHERE T.ROWNUM RMIN AND T.ROWNUM < RMAX</code>

I'm using PHP via ibm_db2 PECL module, but also plan to use Python
soon (most probably via PyDB2). Considering to use stored procedures.
Dima

I'd suggest you start with the following information in the DB2 9
Information Center:

When to use cursors (particularly scollable cursors):
http://publib.boulder.ibm.com/infoce...c/t0005656.htm

Cursors and SQL procedures:
http://publib.boulder.ibm.com/infoce...c/c0024361.htm

Cursors and CLI applications:
http://publib.boulder.ibm.com/infoce...c/c0007645.htm

Differences between scrollable vs. "forward-only" cursors:
http://publib.boulder.ibm.com/infoce...c/c0007649.htm

Cursors and performance considerations (specifically CS isolation
level):
http://publib.boulder.ibm.com/infoce...c/t0005656.htm

Hope this helps.

Jun 28 '07 #2

This discussion thread is closed

Replies have been disabled for this discussion.

Similar topics

11 posts views Thread by Alban Hertroys | last post: by
5 posts views Thread by Todd Huish | last post: by
5 posts views Thread by Just Me | last post: by
6 posts views Thread by a | last post: by
5 posts views Thread by Boni | last post: by
1 post views Thread by mrcraze | last post: by
6 posts views Thread by =?Utf-8?B?bGpsZXZlbmQy?= | last post: by

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.