I have this stored procedure, its working
CREATE PROCEDURE myrange()
BEGIN
SET @start = 0;
PREPARE stmt FROM ' SELECT firstname FROM peoples ORDER BY id LIMIT ?,1 INTO @name';
WHILE @start < 5 DO
EXECUTE stmt USING @start;
CASE
WHEN @name = 'Ana'
THEN INSERT INTO mytable (log) VALUES('yes');
ELSE
INSERT INTO mytable (log) VALUES('no');
END CASE;
SET @start = @start + 1;
END WHILE;
END;
but, if I delete from this procedure, this piece of code:
ELSE
INSERT INTO mytable (log) VALUES('no');
mysqli_error() returns this error: "Case not found for CASE statement".
Someone know, why?