请帮助解决这个MySQL触发器 - 已经搜索过,无法找到语法问题。
获取错误#1064 - 您的SQL语法出错;检查与您的MySQL服务器版本相对应的手册,以便在' @v_index int DEFAULT 1附近使用正确的语法; WHILE @v_index< = NEW.pt_number INSERT INTO Pat'在第9行
DELIMITER $$
CREATE TRIGGER after_insert_calls_insert_patients
AFTER INSERT ON Calls
FOR EACH ROW
BEGIN
DECLARE @v_index int DEFAULT 1;
WHILE @v_index <= NEW.pt_number
INSERT INTO Patients SET
Patient_id = CONCAT(NEW.Calls_id, '-', @v_index),
FK_Calls_id = NEW.Calls_id,
update_by = "SYSTEM";
SET @v_index := @v_index +1;
END WHILE;
END;
$$
DELIMITER ;
答案 0 :(得分:0)
尝试删除@ in&#34; DECLARE @v_index int DEFAULT 1;&#34;