mysql创建存储过程语法错误_Mysql语法错误创建存储过程

莫兴言
2023-12-01

这让我疯了.

CREATE DEFINER=`root`@`localhost` PROCEDURE `CalcularCRTarea` (Id_Tarea INT, OUT crTarea decimal(12, 4))

DETERMINISTIC

BEGIN

DECLARE done BOOLEAN DEFAULT FALSE;

DECLARE _id BIGINT UNSIGNED;

DECLARE cur CURSOR FOR SELECT Id FROM Tarea_Frente where Id_Item_Tarea = Id_Tarea;

DECLARE CONTINUE HANDLER FOR NOT FOUND SET done := TRUE;

OPEN cur;

testLoop: LOOP

FETCH cur INTO _id;

IF done THEN

LEAVE testLoop;

ELSE

CALL CalcularCRFrente(_id, @suma);

SET crTarea = crTarea + @suma;

END IF;

END LOOP testLoop;

CLOSE cur;

END;

phpmyadmin回复我

MySQL said: Documentation

#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 '' at line 4

那将是一条线

DECLARE done BOOLEAN DEFAULT FALSE;

这有什么不对?我尝试了几个小的改动,我总是得到同样的错误.我检查了文档,我没有看到语法错误是什么.

我知道这是一个愚蠢的错误,但是我被困了半个小时.

是一个游标,它迭代每一行并为每一行执行存储过程;我已经用存储的函数完成了它(并且它像魅力一样工作)但是当时在服务器中发布我看到我的共享主机不支持存储的函数,只有存储过程:(所以这是我最好的方式’我找到了.

 类似资料: