1

我正在尝试摆脱单击 GUI 的创建按钮以创建新行的无聊任务,因此我决定定义一个函数来执行此操作多次,但它在 NAVICAT 中返回错误:

CREATE FUNCTION AddRow (number INT)
    BEGIN
        SET @x = 0;
    REPEAT
        INSERT INTO 'result' () VALUES ()
        SET @x += 1;
    UNTIL x > @number END REPEAT;

    END
call AddRow (10)

错误:

[SQL]CREATE FUNCTION AddRow (number INT)
    BEGIN
        SET @x = 0;
    REPEAT
        INSERT INTO 'result' () VALUES ()
        SET @x += 1;
    UNTIL x > @number END REPEAT;

    END
call AddRow (10)

[Err] 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 'BEGIN
        SET @x = 0;
    REPEAT
        INSERT INTO 'result' () VALUES ()
        SET @x += ' at line 2
4

0 回答 0