Cursors retrieve rows one at a time from a query or stored procedure that
has multiple rows in its result set.
A cursor is a handle or an identifier for the query or procedure,
and for a current position within the result set.
Cursor management
Managing a cursor is similar to managing a file in a programming language. The following steps manage cursors:
Cursor Positioning
Cursor positioning is flexible. When a cursor is opened, it is positioned before the first row. You can move the cursor position to an absolute position from the start or the end of the query results, or to a position relative to the current cursor position. The specifics of how you change cursor position, and what operations are possible, are governed by the programming interface.
Cursors on SELECT statements
The following procedure uses a cursor on a SELECT statement. Based on the same query used in the ListCustomerValue procedure, it illustrates several features of the stored procedure language.