创建 MySQL 存储过程的简单语法为:
CREATE PROCEDURE 存储过程名称( [in | out | inout] 参数 ) BEGIN Mysql 语句 END
调用存储过程:
call 存储过程名称() // 名称后面要加()
<span style="color: rgb(57, 57, 57); font-family: verdana, 'ms song', Arial, Helvetica, sans-serif; font-size: 14px; line-height: 21px; background-color: rgb(250, 247, 239);">二 、 REPEAT 循环</span>
<pre name="code" class="html">delimiter // drop procedure if exists looppc; create procedure looppc() begin declare i int; set i = 1; repeat insert into user_profile_company (uid) values (i+1); set i = i + 1; until i >= 20 end repeat; end // ---- 调用 call looppc()
三、 LOOP 循环
delimiter $$ drop procedure if exists lopp; create procedure lopp() begin declare i int ; set i = 1; lp1 : LOOP // lp1 为循环体名称 LOOP 为关键字insert into user_profile (uid) values (i); set i = i+1; if i > 30 then leave lp1; // 离开循环体 end if; end LOOP; // 结束循环 end $$
更多Mysql内容来自木庄网络博客
标签:Mysql
相关阅读 >>
更多相关阅读请进入《mysql》频道 >>

数据库系统概念 第6版
本书主要讲述了数据模型、基于对象的数据库和XML、数据存储和查询、事务管理、体系结构等方面的内容。