syntax error for mysql declaration of variable

前端 未结 2 1706
野的像风
野的像风 2020-12-29 04:26
CREATE PROCEDURE dorepeat(IN p1 INT)
BEGIN
  DECLARE x INT DEFAULT 0;
  REPEAT SET x = x + 1; UNTIL x > p1 END REPEAT;
END

I get an syntax error

2条回答
  •  醉话见心
    2020-12-29 04:39

    You need to temporarily change the delimiter so the MySQL client doesn't think you're done with your statement when it sees the semicolon on line 3:

    DELIMITER //
    
    CREATE PROCEDURE dorepeat(IN p1 INT)
    BEGIN
      DECLARE x INT DEFAULT 0;
      REPEAT SET x = x + 1; UNTIL x > p1 END REPEAT;
    END//
    
    DELIMITER ;
    

提交回复
热议问题