日期:2014-05-16  浏览次数:20737 次

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