You have specified host variables for a cursor on both the DECLARE and the OPEN statements. In the static case, you should specify the host variables on the DECLARE statement. In the dynamic case, specify them on the OPEN.