2223 Cursor is not on a valid row

Advantage Error Guide

Problem: Data from the column could not be read because the cursor is not on a valid row. The row pointer is either before the first row or after the last row in the cursor.

Solution: Check the error message for the location of the error in the script. Verify that FETCH is called on the cursor before reading the column data and that the result from the FETCH statement is checked before trying to access the data.