全部博文(99)
分类: Mysql/postgreSQL
2011-09-19 10:25:22
9094133352011-09-19 11:13:01
修改了存储过程,用一个参数来代替是取最大值还是最小值
create procedure sp1(str varchar(1000),voption TINYINT)
begin
if voption =1 then
set @p=concat('select greatest(',str,')');
else
set @p=concat('select LEAST(',str,')');
end if;
PREPARE stmt1 FROM @p;
EXECUTE stmt1 ;
DEALLOCATE PREPARE stmt1;
end;