Re: Stored procedure problem with variable limit
Kim <kimslot@gmail.com> wrote in
<5c7b07e9-65fe-4973-b042-e88bff5d42c8@2g2000hsn.googlegroups.com>:
> Im using MySQL 5.1 to create a stored procedure, but
> without luck.
>
> Query:
> DELIMITER /
> CREATE PROCEDURE _test()
> BEGIN
> DECLARE x INT;
> SET x = 5;
> SELECT * FROM tbl LIMIT x;
> END
>
> I get this error:
> #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 'x;
> END' at line 5
>
> ..and I have no idea why. Anyone knows why ?
Have you checked the manual, as the error message itself
suggests?
MySQL Reference Manual, 12.2.7, section on LIMIT clause,
describes the limitation you've run into, as well as a
suggested workaround.
--
In Soviet Russia, XML documents transform *you*. |