Home  >  Article  >  Database  >  使用navicat工具创建MySQL存储过程_MySQL

使用navicat工具创建MySQL存储过程_MySQL

WBOY
WBOYOriginal
2016-05-31 08:46:322663browse

Navicat

使用Navicat for MySQL工具创建存储过程步骤:

1. 新建函数(选择函数标签 -> 点击新建函数):

2.输入函数的参数个数、参数名、参数类型等:

 

3.编写存储过程:

 代码如下:

BEGIN /* 定义变量 */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 ;				-- 可以加入insert,update等语句/* 循环结束 */end loop myLoop;/* 关闭游标 */close myCursor;END

4.保存(请输入合法名称):

 

5.运行存储过程(在结果1,2,3...中可以查询输出信息):

 

Statement:
The content of this article is voluntarily contributed by netizens, and the copyright belongs to the original author. This site does not assume corresponding legal responsibility. If you find any content suspected of plagiarism or infringement, please contact admin@php.cn