Chapter 5. Understanding and Using Cursors and Result Sets

In this chapter, you will learn

  • What a cursor is

  • How to use cursors inside SQL procedures

  • How to perform positioned deletes and positioned updates

  • How cursors affect locking

  • About cursor behavior on commit and rollback

  • How to use nested save points

  • How cursors are used to return result sets to applications.

In previous chapters, you have seen how SQL procedures can manipulate table data by directly executing INSERT, UPDATE, and DELETE statements. Using SQL in this manner, however, means that operations must be applied to the entire set of data defined by the WHERE clause of the statement. In SQL procedures, it is possible to define a set of data rows (which will be called a result set from here ...

Get DB2® SQL PL: Essential Guide for DB2® UDB on Linux™, UNIX®, Windows®, i5/OS™, and z/OS®, Second Edition now with the O’Reilly learning platform.

O’Reilly members experience books, live events, courses curated by job role, and more from O’Reilly and nearly 200 top publishers.