Cursors

A cursor is an embedded SQL query that returns multiple rows. The cursor identifies the current row from a SELECT operation that returns multiple rows.

When you work with a cursor, you:

  1. DECLARE the cursor, which identifies it to the program.
  2. OPEN the cursor, which starts the SELECT process.
  3. FETCH until not found, which positions the cursor at each row that meets the conditions set in the SELECT statement and INSERTs the value as designated in the SELECT statement.
  4. CLOSE the cursor, which ends the SELECT operation and releases any resources that had been assigned to the cursor.