首页 > 数据库技术 > 详细

mysql基础四 存储过程

时间:2018-03-20 15:08:20      阅读:185      评论:0      收藏:0      [点我收藏+]
一、存储过程:变量的声明和赋值。

create procedure p1()

begin

declare age int default 18;

    set age :=age+20;

select age from dual;

end;

调用存储过程:call p1(); 其结果是如下:

技术分享图片

二、存储过程:简单的控制语句。

create procedure p2()
begin

declare age int default 18;
if age>=18 then
 select ‘已成年‘ ;
else 
 select ‘未成年‘;
end if;

end;
调用存储过程:call p2(); 其结果是如下:
技术分享图片

mysql基础四 存储过程

原文:http://blog.51cto.com/8757576/2088961

(0)
(0)
   
举报
评论 一句话评论(0
关于我们 - 联系我们 - 留言反馈 - 联系我们:wmxa8@hotmail.com
© 2014 bubuko.com 版权所有
打开技术之扣,分享程序人生!