

SQL Statements › FETCH › Processing
Processing
An open cursor has three possible positions, as follows:
- Before a row: A cursor is positioned before a row either after an OPEN whose result set contains at least one row, or after a DELETE. If the cursor is currently positioned before a row, the cursor is positioned on that row, and values are assigned to host variables as specified by INTO.
- On a row: A cursor is positioned on a row as the result of a FETCH that finds a row. After an UPDATE, the cursor is still positioned on the same row. If a cursor is on a row, that row is called the current row of the cursor. If the cursor is positioned on a row other than the last row, the cursor is positioned on the next row, and values of that row are assigned to host variables as specified by INTO.
- After the last row: A cursor is positioned after the last row either after an OPEN whose result set contains no rows, or after the last row has been fetched. If the cursor is currently positioned on or after the last row of the result table, the SQLCODE value is set to +100, the cursor is positioned after the last row, and values are not assigned to host variables.
A cursor referenced in an UPDATE or DELETE statement must be positioned on a row. A cursor can only be positioned on a row as a result of a FETCH statement. If an error occurs during the execution of a FETCH statement that makes the position of a cursor unpredictable, the cursor is closed.
Copyright © 2014 CA.
All rights reserved.
 
|
|