此代码显示参数声明中的语法错误。请帮我解决
DELIMITER $$
CREATE DEFINER=`root`@`localhost` PROCEDURE `ADDCOURSE`(@Course varchar(45),@Branch varchar(45),@Batch INT)
BEGIN
DECLARE I INT;
SET I=1;
LABEL1: LOOP
INSERT INTO course
(Course, Branch, Batch)
VALUES(@Course, @Branch, I);
IF I <= @Batch THEN
SET I=I+1;
ITERATE LABEL1;
END IF;
LEAVE LABEL1;
END LOOP LABEL1;
END
答案 0 :(得分:1)
请改为尝试:
DELIMITER $$
CREATE DEFINER = `root`@`localhost` PROCEDURE ADDCOURSE(
Course varchar(45), Branch varchar(45), Batch INT
)
BEGIN
DECLARE I INT;
SET I = 1;
LABEL1: LOOP
INSERT INTO course
(Course, Branch, Batch)
VALUES(@Course, @Branch, I);
IF I <= @Batch THEN
SET I=I+1;
ITERATE LABEL1;
END IF;
LEAVE LABEL1;
END LOOP LABEL1;
END
$$
CREATE DEFINER = `root`@`localhost` PROCEDURE ADDCOURSE(
Course varchar(45), Branch varchar(45), Batch INT
)
BEGIN
DECLARE I INT;
SET I = 1;
LABEL1: LOOP
INSERT INTO course
(Course, Branch, Batch)
VALUES(@Course, @Branch, I);
IF I <= @Batch THEN
SET I=I+1;
ITERATE LABEL1;
END IF;
LEAVE LABEL1;
END LOOP LABEL1;
END
$$