WHILE @idx <= @len DO SET accinterval1 = TRIM(SUBSTRING_INDEX(SUBSTRING_INDEX(temp_accintervals, ',', @idx), ',', -1)); SELECT accinterval1; /** * 取卷内条目数 */ SELECT count( 1 ) INTO records FROM t_ams_recordother t WHERE t.archivesym = accinterval1 AND FONDSCODE = '2110000' AND bookid = 0 and classno in ('银行余额调节表','银行对账单'); select records ; IF records =0 then SELECT concat(accinterval1,' - 未查询到需要组卷的数据'); SET @idx = @idx + 1; CONTINUE; end if; SET @idx = @idx + 1; END WHILE;为什么continue在报错
时间: 2024-01-28 15:04:06 浏览: 52
mysql基础语法&存储过程示例.pdf
根据你提供的代码,`CONTINUE` 的报错可能是因为 `CONTINUE` 关键字不能单独使用,必须在循环内部使用。在你的代码中,`CONTINUE` 语句的位置不在循环内部,导致报错。
你应该将 `CONTINUE` 语句放在 `WHILE` 循环内部的条件语句中,例如:
```
WHILE @idx <= @len DO
SET accinterval1 = TRIM(SUBSTRING_INDEX(SUBSTRING_INDEX(temp_accintervals, ',', @idx), ',', -1));
SELECT accinterval1;
/** 取卷内条目数 */
SELECT count( 1 ) INTO records FROM t_ams_recordother t WHERE t.archivesym = accinterval1 AND FONDSCODE = '2110000' AND bookid = 0 and classno in ('银行余额调节表','银行对账单');
SELECT records ;
IF records = 0 THEN
SELECT concat(accinterval1,' - 未查询到需要组卷的数据');
SET @idx = @idx + 1;
CONTINUE WHILE;
END IF;
SET @idx = @idx + 1;
END WHILE;
```
在上述代码中,`CONTINUE` 语句被放在了 `IF` 条件语句中,并且标明了 `WHILE` 循环的名称,以此来实现跳过本次循环。
阅读全文