Error
SQLCODE -514
PREPARE with open cursor
Explanation
PREPARE attempted while cursor using the statement is open.
Solution
CLOSE cursor before PREPARE, then reopen.
Example
Reusing prepared statement with open cursor