立即学习:https://edu.csdn.net/course/play/27328/370712?utm_source=blogtoedu
#存储过定义:求两数之和
delimiter //
create procedure my_sum(in a int, in b int, out result int)
bedin
set result = a + b;
end
//
delimiter;
#存储过程调用
call my_sum(10. 20, @result);
select @result;
delimiter //
create procedure my_n_sum(in n int, out result int)
begin
declare i int default 1;
declare sum int default 0;
while i <= n do
set sum = sum + i;
set i = i + 1;
end while;
set result = sum;
end;
//
delimiter ;
call my_n_sum(10, @result);
select @result;