0

此代码在参数声明中显示语法错误。请帮我解决

分隔符 $$

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
4

1 回答 1

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

$$

于 2012-06-22T18:52:48.670 回答