delimiter |; create procedure sp1() begin declare continue handler for SQLEXCEPTION begin end; execute pstmt1; if @a < 1 then prepare pstmt1 from 'select 1'; set @a := 1; else prepare pstmt1 from 'select 2'; end if; execute pstmt1; end | delimiter ;| set @a := 0; call sp1(); execute pstmt1; call sp1(); call sp1();