Home > Database > Mysql Tutorial > MySQL 有输入输出参数的存储过程实例_MySQL

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

WBOY
Release: 2016-06-01 13:19:44
Original
1085 people have browsed it

bitsCN.com 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'
bitsCN.com

Related labels:
source:php.cn
Statement of this Website
The content of this article is voluntarily contributed by netizens, and the copyright belongs to the original author. This site does not assume corresponding legal responsibility. If you find any content suspected of plagiarism or infringement, please contact admin@php.cn
Popular Tutorials
More>
Latest Downloads
More>
Web Effects
Website Source Code
Website Materials
Front End Template