Mysql paging stored procedure call error

has not written a stored procedure before. I encountered this problem for the first time and didn"t understand it. I hope some great god can give me some advice! < span class= "emoji emoji-pray" >

  • The sql statement is as follows :
CREATE DEFINER=`root`@`%`
PROCEDURE `pager`
(
    IN `table_name` varchar(50),
    IN `columes` varchar(200),
    IN `page_size` int,
    IN `page_now` int,
    IN `where_str` varchar(200),
    IN `order_str` varchar(200),
    OUT `out_rows` int
 )
    DETERMINISTIC
    COMMENT ""
BEGIN
    DECLARE m_begin_row INT DEFAULT 0;
    DECLARE m_limit_string CHAR(64);

    SET m_begin_row = (page_now - 1) * page_size;
    SET m_limit_string = CONCAT("LIMIT", m_begin_row, ",", page_size);

    SET @COUNT_STRING = CONCAT("SELECT COUNT(*) INTO @ROWS_TOTAL FROM ", table_name, " ", where_str);
    SET @MAIN_STRING = CONCAT("SELECT ", columes, " FROM ", table_name, " ", where_str, " ", order_str,m_limit_string);

    PREPARE count_stmt FROM @COUNT_STRING;
    EXECUTE count_stmt;
    DEALLOCATE PREPARE count_stmt;
    SET out_rows = @ROWS_TOTAL;

    PREPARE main_stmt FROM @MAIN_STRING;
    EXECUTE main_stmt;
    DEALLOCATE PREPARE main_stmt;
END
  • call parameters are as follows:
call pager("bco_cms.cms_coupon_user","*",1,3,"","",@result);
  • the error is as follows:
1064 - You have an error in your SQL syntax; check the manual that corresponds to your MySQL server version for the right syntax to use near "1" at line 1
May.26,2021

lose a space after LIMIT

SET m_limit_string = CONCAT('LIMIT ', m_begin_row, ',', page_size);
MySQL Query : SELECT * FROM `codeshelper`.`v9_news` WHERE status=99 AND catid='6' ORDER BY rand() LIMIT 5
MySQL Error : Disk full (/tmp/#sql-temptable-64f5-1e46507-4c2ad.MAI); waiting for someone to free some space... (errno: 28 "No space left on device")
MySQL Errno : 1021
Message : Disk full (/tmp/#sql-temptable-64f5-1e46507-4c2ad.MAI); waiting for someone to free some space... (errno: 28 "No space left on device")
Need Help?