Result set processing Shows how to fetch rows from a database query. Understanding database result sets This is an introduction to database result sets. DECLARE (result set cursor) Associates a database cursor with an SQL statement producing a result set. OPEN (result set cursor) Executes the SQL statement with result set associated with the specified database cursor FETCH (result set cursor) Moves a cursor to a new row in the corresponding result set and retrieves the row values into fetch buffers. CLOSE (result set cursor) Closes a database cursor and frees resources allocated on the database server for the result set. FREE (result set cursor) Releases SQL cursor resources allocated by the DECLARE instruction. FOREACH (result set cursor) Processes a series of data rows returned from a database cursor.