用navicat工具创建MySQL存储过程
时间:2021-07-01 10:21:17
帮助过:5人阅读
/* 定义变量 */
declare tmp0 VARCHAR(1000);
declare tmp1 VARCHAR(1000);
declare done int default -1;
/* 声明游标 */
declare myCursor cursor for select cell_0,cell_1 from t_test;
/* 当游标到达尾部时,mysql自动设置done=1 */
declare continue handler for not found set done=1;
/* 打开游标 */
open myCursor;
/* 循环开始 */
myLoop: LOOP
/* 移动游标并赋值 */
fetch myCursor into tmp0,tmp1;
if done = 1 then
leave myLoop;
end if;
/* do something */
select tmp0,tmp1 ;
/* 循环结束 */
end loop myLoop;
/* 关闭游标 */
close myCursor;
END
4.保存(请输入合法名称):
![技术分享图片](https://img.gxlcms.com//Uploads-s/new/2020-10-14-qlqqti/9b79f762-a7b6-3fb8-b45c-216ddf279218.jpg)
5.运行存储过程(在结果1,2,3...中可以查询输出信息):
![点击查看原始大小图片 技术分享图片](https://img.gxlcms.com//Uploads-s/new/2020-10-14-qlqqti/469d605f-4051-3180-8cec-43ef47c7a541.jpg)
用navicat工具创建MySQL存储过程
标签:etc 语句 mys 编写 函数标签 idt png 退出 tin