Archive for 2008
MySQL: passing limits as stored procedure parameters
Unfortunately MySQL 5 (at least 5.0.15) does not allow using variables or procedure parameters with LIMIT.
Here is a workaround where SQL statement is generated inside stored procedure:
CREATE PROCEDURE GetList (limitStart INT, limitCount INT) BEGIN SET @SQL = CONCAT('SELECT ID, Name FROM `User` LIMIT ', limitStart, ', ', limitCount); PREPARE query FROM @SQL; EXECURE query; DEALLOCATE PREPARE query; END; |