Limiting selected rows count with a stored procedure parameter in MySQL

Posted by ssobczak on Stack Overflow See other posts from Stack Overflow or by ssobczak
Published on 2010-03-08T15:19:40Z Indexed on 2010/03/08 15:21 UTC
Read the original article Hit count: 316

Filed under:
|
|
|

I have a procedure SelectProc wich contains SELECT statement. I want to add a procedure param LimitRowsCount and use it as following:

CREATE PROCEDURE SelectProc (IN LimitRowsCount INTEGER UNSIGNED) 
BEGIN
   SELECT (...)
   LIMIT LimitRowsCount;
END

but this approach doesn't work.

The SELECT itself contains nested subqueries so I can't create view from it. Is there a way more propper then dynamic SQL (prepared statements) ?

© Stack Overflow or respective owner

Related posts about mysql

Related posts about select