Вот сам запрос:
DELIMITER //
CREATE PROCEDURE `SelectPerson` (OUT `cha` TEXT)
LANGUAGE SQL
DETERMINISTIC
SQL SECURITY DEFINER
COMMENT 'Some proc!'
BEGIN
DECLARE minimal INT;
SET minimal = 100;
DECLARE ids Int;
SET ids = 1;
DECLARE r,cr,a Int;
DECLARE reit CURSOR FOR SELECT reiting,id FROM stud;
DECLARE CONTINUE HANDLER FOR NOT FOUND SET ids = 0;
OPEN reit;
WHILE ids = 1 DO
FETCH reit INTO r,a;
IF ids = 1
IF r < minimal THEN
Set minimal = r;
SET cr = SELECT name FROM stud WHERE id = a;
END IF;
END IF;
END WHILE;
CLOSE reit;
SET cha = cr;
END
Выдает ошибку:
#1064 - You have an error in your SQL syntax; check the manual that corresponds to your MySQL server version for the right syntax to use near 'DECLARE ids Int;