Declaring a row cursor
Before you can use a row-positioned cursor to retrieve rows, you must declare the cursor. When you declare a cursor, you identify a set of rows that are to be accessed with the cursor.
To declare a row cursor, issue a DECLARE CURSOR statement. The DECLARE CURSOR statement names a cursor and specifies a prepared SELECT statement. The SELECT statement defines the criteria for the rows that are to make up the result segment.
The following example shows a cursor named C1 that is declared using a simple form of the DECLARE CURSOR statement for a prepared statement STMT.
EXEC SQLIMS
DECLARE C1 CURSOR FOR STMT
END-EXEC.