SQL0121S cursor cursor not declared

An OPEN, FETCH or CLOSE statement references a cursor name that was not DECLAREd.
Restriction: This topic applies to Windows environments only.

The DECLARE CURSOR statement must be coded before an OPEN, FETCH or CLOSE SQL statement. If defined, move the DECLARE CURSOR statement before the statement in error. Otherwise, check to make sure the cursor name used in the DECLARE CURSOR statement matches the cursor name used in the SQL statement in error.