CREATE PROCEDURE sp_GetInfo( in _where varchar(2000), in _orderby varcahr(200), in _pageindex int, in _pagesize int, out _totalcount) BEGIN SET @startrow = _pagesize * (_pageindex - 1) ; SET @pagesize = _pagesize ; set @strsql='select * from feedback'; SET @strwhere = CONCAT( CASE IFNULL(_where, '') WHEN '' THEN '' ELSE CONCAT(' where 1=1 ', _where) END, CASE IFNULL(_orderby, '') WHEN '' THEN '' ELSE CONCAT(' order by ', _orderby) END ) ; set @sql1=CONCAT(@strsql,@strwhere); PREPARE sql1 FROM @sql1; EXECUTE sql1; SET _totalcount = FOUND_ROWS(); set @sql2=CONCAT(@strsql,@strwhere, CASE WHEN _pagesize=0 THEN '' ELSE CONCAT(' limit ',@startRow,',',@pageSize) END); PREPARE sql2 FROM @sql2; EXECUTE sql2 ; END
mysql存储过程区别sqlserver
参数形式,
分号“;”