Use a cursor

When SQL runs a select statement, the resulting rows comprise the result table. A cursor provides a way to access a result table.

It is used within an SQL program to maintain a position in the result table. SQL uses a cursor to work with the rows in the result table and to make them available to your program. Your program can have several cursors, although each must have a unique name.

Statements related to using a cursor include the following:

Related reference
Update data as it is retrieved from a table
Related information
DECLARE CURSOR statement
CLOSE statement
FETCH statement
DELETE statement
UPDATE statement