create procedure p1(t1 int,j char(1))
begin
if j='h' then
SELECT * FROM table where num>t1;
else
SELECT * FROM table where num<t1;
end if;
end$
调用存储过程:call [存储过程的名](t1,j); 例二:
//计算1->n的和
create procedure p2(n smallint)
begin
declare i int;//声明变量
declare s int;
set i=1;//赋值
set s=0;
while i<=n do
set s=s+i;
set i=i+1;
end while;
select s;
end$
call p2(100);//返回1+2+...+100的和