This FLUSH statement refers to a cursor that is associated with a SELECT statement, not an INSERT statement. FLUSH is only appropriate with insert cursors. Review the program to ensure that the correct cursor has been named.