当前位置: 移动技术网 > IT编程>数据库>Mysql > MySQL 有输入输出参数的存储过程实例

MySQL 有输入输出参数的存储过程实例

2017年12月12日  | 移动技术网IT编程  | 我要评论
1、实例
复制代码 代码如下:

delimiter //
drop procedure if exists `test`.`p_getvalue` //
create definer=`root`@`localhost` procedure `p_getvalue`(
in id varchar(20),out s varchar(20)
)
begin
if (length(id)=11) then select 'a_b_c_d' into s;
elseif(length(id)=8) then select 'a_b_c' into s;
elseif(length(id)=5) then select 'a_b' into s;
elseif(length(id)=2) then select 'a' into s;
end if;
select s;
end //
delimiter ;

2、调用
复制代码 代码如下:

call p_getvalue('11000112',@s)

3、结果
'a_b_c'

如对本文有疑问, 点击进行留言回复!!

相关文章:

验证码:
移动技术网