The SQL mode ANSI and DB2 require that a result table generated by DECLARE CURSOR is closed using a <CLOSE statement>, before the result table name can be used to open a new result table within the same transaction.
Insert a CLOSE statement in the application.