1.navicat新建存储过程

  Mysql_存储过程 随笔 第1张

SRE实战 互联网时代守护先锋,助力企业售后服务体系运筹帷幄!一键直达领取阿里云限量特价优惠。

  选择 过程

  Mysql_存储过程 随笔 第2张

  增加输入输出参数(若是无参,直接点击完成)

  完成后代码如下:

CREATE DEFINER = CURRENT_USER PROCEDURE `kxy_prco2`()
BEGIN
    #Routine body goes here...

END;

2.添加代码

  2.1 无参

CREATE DEFINER=`root`@`%` PROCEDURE `kxy_proc2`()
BEGIN
    #Routine body goes here...
    UPDATE v5_service_type t set t.lastmodifyuser='kxy2' where t.service_type_code='01';
END

  调用

call kxy_proc2();

  2.2 带参

CREATE DEFINER=`root`@`%` PROCEDURE `kxy_proc`(in typecode VARCHAR(20),out typename VARCHAR(20))
BEGIN
    #Routine body goes here...
    SELECT t.service_type_name into typename from v5_service_type t WHERE t.service_type_code=typecode;
END

  调用

set @typecode='01';
set @typename='';
call kxy_proc(@typecode,@typename);
SELECT @typename;

 

扫码关注我们
微信号:SRE实战
拒绝背锅 运筹帷幄