一个简单的循环问题
CREATE DEFINER = `dba`@`xx.xx.xx.3` PROCEDURE `oninjadb`.`TESTLOOPER`()
LANGUAGE SQL
DETERMINISTIC
NO SQL
SQL SECURITY DEFINER
COMMENT ''
BEGIN
DECLARE counter INT default 0;
simple_loop: LOOP
SET counter=counter+1;
select counter;
IF counter=100 THEN
leave simple_loop;
END IF;
end loop simple_loop;
END
好吧,一个简单的循环问题,从谷歌搜索复制而来。唯一的问题是循环不会经过多次,因此输出为 1,仅此而已。我知道这是一个简单的循环,但我需要得到它,以便继续解决更复杂的问题。提前致谢...
CREATE DEFINER = `dba`@`xx.xx.xx.3` PROCEDURE `oninjadb`.`TESTLOOPER`()
LANGUAGE SQL
DETERMINISTIC
NO SQL
SQL SECURITY DEFINER
COMMENT ''
BEGIN
DECLARE counter INT default 0;
simple_loop: LOOP
SET counter=counter+1;
select counter;
IF counter=100 THEN
leave simple_loop;
END IF;
end loop simple_loop;
END
Okay a simple loop problem, copied from a google search. The only problem is that the loop won't pass thru more than once, so the output is 1 and that's it. I know this is a simple loop, but I need to get it so I move on to more complicated problems. Thanks in advance...
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(2)
您的程序实际上正在运行 100 个查询。 第一个查询返回数字为 1 的结果。其他 99 个结果集返回正确的数字。
过程能够从多个查询返回多个结果集。您读回这些不同结果集的能力取决于您使用的 API。
Your procedure is actually running 100 queries. The first query is returning a result with the number 1. The 99 other results sets are returning the correct numbers.
Procedures are able to return multiple result sets from multiple queries. Your ability to read back those different result sets depends on the API you are using.
这可能会让你重回正轨:)
this might get you back on track :)