>  기사  >  데이터 베이스  >  MySQL 有输入输出参数的存储过程实例

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

WBOY
WBOY원래의
2016-06-07 18:01:32844검색

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

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'
성명:
본 글의 내용은 네티즌들의 자발적인 기여로 작성되었으며, 저작권은 원저작자에게 있습니다. 본 사이트는 이에 상응하는 법적 책임을 지지 않습니다. 표절이나 침해가 의심되는 콘텐츠를 발견한 경우 admin@php.cn으로 문의하세요.