存储过程——存储函数

1.存储函数

存储函数的弊端,必须要有返回值,能使用存储函数的地方也能使用存储过程。
在这里插入图片描述
案例需求
在这里插入图片描述

create function fun1(n int)
returns int deterministic
begin
	declare total int default 0;
	while n>0 do
		set total := total +_n;
		set n := n - 1;
	end while;

	return total;
end;

select fun1(100);

猜你喜欢

转载自blog.csdn.net/weixin_44860226/article/details/131927519