DROP PROCEDURE IF EXISTS vtzero_good.event_select_requestor;
delimiter &&
CREATE PROCEDURE vtzero_good.`event_select_requestor`(in req varchar(20),in type int,in curpage int)
BEGIN
DECLARE sqllimit varchar(500);
set sqllimit='select id,requestor,operator,priority,title,startdate,enddate from event where requestor= ' ;
if (curpage<=0) then
set curpage=0;
end if;
case type
when 0 then
set sqllimit=concat(sqllimit,"'", req,"' limit ", curpage,',15');
when 1 then
set sqllimit=concat(sqllimit,"'", req,"' and enddate='0001-01-01' limit ", curpage,' ,15');
when 2 then
set sqllimit=concat(sqllimit,"'", req,"' and enddate>'0001-01-01' limit ", curpage,' ,15');
end case;
set @sql = sqllimit;
PREPARE stmt FROM @sql;
EXECUTE stmt;
DEALLOCATE PREPARE stmt;
END &&
mysql存储过程执行动态sql
最新推荐文章于 2024-06-16 09:39:43 发布