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

数据库评论621字数 96阅读模式

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

1、实例很文博客-https://www.zhenjiekeji.com/50760.html

  1. DELIMITER // 
  2. DROP PROCEDURE IF EXISTS `test`.`p_getvalue` // 
  3. CREATE DEFINER=`root`@`localhost` PROCEDURE `p_getvalue`(
  4. in id varchar(20),out s varchar(20)
  5. )
  6. begin
  7. if (length(id)=11) then select 'A_B_C_D' into s;
  8. elseif(length(id)=8) then select 'A_B_C' into s;
  9. elseif(length(id)=5) then select 'A_B' into s;
  10. elseif(length(id)=2) then select 'A' into s;
  11. end if;
  12. select s;
  13. end // 
  14. DELIMITER ;

2、调用很文博客-https://www.zhenjiekeji.com/50760.html

  1. CALL p_getvalue('11000112',@S)

3、结果很文博客-https://www.zhenjiekeji.com/50760.html

'A_B_C'很文博客-https://www.zhenjiekeji.com/50760.html 很文博客-https://www.zhenjiekeji.com/50760.html

weinxin
我的微信
微信号已复制
扫一扫更精彩
大家的支持是我更新的动力!!!
匿名

发表评论

匿名网友