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