您好,欢迎来到三六零分类信息网!老站,搜索引擎当天收录,欢迎发信息

mysql存储过程的写法

2025/11/16 2:14:12发布23次查看
可以使用 create procedure 语句创建存储过程。
数据库存储过程语法格式如下:
create procedure 过程名([[in|out|inout] 参数名 数据类型[,[in|out|inout] 参数名 数据类型…]]) [特性 ...] 过程体delimiter // create procedure myproc(out s int) begin select count(*) into s from students; end //delimiter ;
例:创建一个简单的存储过程
-- ------------------------------ procedure structure for `proc_adder`-- ----------------------------drop procedure if exists `proc_adder`;delimiter ;;create definer=`root`@`localhost` procedure `proc_adder`(in a int, in b int, out sum int)begin #routine body goes here... declare c int; if a is null then set a = 0; end if; if b is null then set b = 0; end if;set sum = a + b;end;;delimiter ;
执行以上存储结果,验证是否正确,如下图
set @b=5;call proc_adder(2,@b,@s);select @s as sum;
以上就是mysql存储过程的写法的详细内容。
该用户其它信息

VIP推荐

免费发布信息,免费发布B2B信息网站平台 - 三六零分类信息网 沪ICP备09012988号-2
企业名录 Product