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'
如对本文有疑问,
点击进行留言回复!!
网友评论