读书人

mysql存储过程的一个容易例子

发布时间: 2012-07-02 17:46:22 作者: rapoo

mysql存储过程的一个简单例子
create procedure hello()
begin
declare a int default 0;
declare b int;
declare c int default 0;
set a = 1;
set b =2;

if a> b || a=1 then
set c= a + b;
end if;
select c as sum;
end;

=========================

CREATE PROCEDURE `sum1`( 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;
end

读书人网 >Mysql

热点推荐