当前位置:Gxlcms > 数据库问题 > MySQL创建存储过程

MySQL创建存储过程

时间:2021-07-01 10:21:17 帮助过:13人阅读

存储过程和函数的区别参考链接:

http://www.cnblogs.com/lengbingshy/archive/2010/02/25/1673476.html

创建存储过程:

DROP PROCEDURE mypro;
CREATE procedure mypro (sid INT,OUT sCount INT)
BEGIN

SELECT COUNT(*) INTO sCount from student where id = sid;
END

执行该存储过程:

CALL mypro(1,@c);
select @c;

创建函数:

DROP FUNCTION myfun;
CREATE FUNCTION myfun (sid INT)
RETURNS int
BEGIN
DECLARE sCount int;
SELECT COUNT(*) INTO sCount from student where id=sid;
RETURN sCount;
END

执行函数:
SELECT myfun(1)

MySQL创建存储过程

标签:bsp   sql   blog   log   com   end   begin   logs   html   

人气教程排行