DELIMITER $$
CREATE PROCEDURE insert_priority_rows()
BEGIN
DECLARE max_heuristics INT DEFAULT 10;
DECLARE heuristic_ID INT;
DECLARE cur CURSOR FOR
SELECT heuristicID
FROM heuristics;
DECLARE CONTINUE HANDLER
FOR NOT FOUND SET heuristic_ID = 0;
DECLARE @study_ID INT;
SELECT MAX(studyID) INTO @study_ID FROM study;
OPEN cur;
REPEAT
FETCH cur INTO heuristic_ID;
IF heuristic_ID = 0 THEN
LEAVE;
END IF;
INSERT INTO heuristic_priority (studyID, heuristicID, h_priority)
VALUES (@study_ID, heuristic_ID, 'm');
UNTIL heuristicID = 0 END REPEAT;
CLOSE cur;
END$$
DELIMITER ;
它抛出如下错误:
1064-SQL语法中有错误;检查与您的MariaDB服务器版本对应的手册,以获得在"@study_ID INT "附近使用的正确语法;
我应该做些什么来纠正这个问题?
1条答案
按热度按时间ldxq2e6h1#
你不需要大部分的代码,循环可以用下面的查询来代替: