mysql 创建存储过程问题

来源:百度知道 编辑:UC知道 时间:2024/05/19 14:44:54
无语

没人会吗?

一、MySQL 创建存储过程
“pr_add” 是个简单的 MySQL 存储过程,这个存储过程有两个 int 类型的输入参数 “a”、“b”,返回这两个参数的和。

drop procedure if exists pr_add;

-- 计算两个数之和

create procedure pr_add
(
a int,
b int
)
begin
declare c int;

if a is null then
set a = 0;
end if;

if b is null then
set b = 0;
end if;

set c = a + b;

select c as sum;

/*
return c; -- 不能在 MySQL 存储过程中使用。return 只能出现在函数中。
*/
end;

具体一点

目前只有5.0以上版本才能用存储过程与计划任务