Aurora MySQL中的WHILE-DO语句的正确语法是什么

0

【以下的问题经过翻译处理】 我正在尝试在Aurora MySQL中创建一个WHILE循环。使用以下语法:

SET @inc = 0;

WHILE @inc <= 5 DO SET @inc = @inc + 1;END;

在'WHILE @inc <= 5 DO'处提示了语法错误。

Aurora MySQL中的正确语法是什么?

我的AURORA_VERSION()版本是2.10.0。

profile picture
EXPERT
asked 9 months ago34 views
1 Answer
0

【以下的回答经过翻译处理】 需要按照此处的说明 here 添加分隔符。

我在 Aurora MySQL 2.10.0 上测试了以下内容可以成功执行:

delimiter //
CREATE PROCEDURE dowhile()
  BEGIN
   DECLARE v1 INT DEFAULT 5;
    WHILE v1 > 0 DO
     SET v1 = v1 - 1;
   END WHILE;
 END; //
delimiter ;

profile picture
EXPERT
answered 9 months ago

You are not logged in. Log in to post an answer.

A good answer clearly answers the question and provides constructive feedback and encourages professional growth in the question asker.

Guidelines for Answering Questions