473,386 Members | 1,819 Online
Bytes | Software Development & Data Engineering Community
Post Job

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 473,386 software developers and data experts.

Dynamic set limit error

Hi
I am trying to create a procedure that does a lot of stuff, but the error comes in when i try to execute the select statement and dynamicaly set the limit. The following is the procedure which gives the error.

DELIMITER ^

DROP PROCEDURE IF EXISTS `serverName`.`procedureName`^

CREATE PROCEDURE `serverName`.`procedureName` (nLimit INT)
BEGIN

SELECT column FROM tableName
order by column LIMIT nLimit OFFSET 0;

END^

DELIMITER ;

When i try the following, it works:

DELIMITER ^

DROP PROCEDURE IF EXISTS `serverName`.`procedureName`^

CREATE PROCEDURE `serverName`.`procedureName` (nLimit INT)
BEGIN

SELECT column FROM tableName
order by column LIMIT 5 OFFSET 0;

END^

DELIMITER ;

Any idea why the first one does not work??

Thanks in advance
Sep 11 '06 #1
2 3092
Ok, it is not a bug, it's a limitation. The sollution or workaround is found here: http://dev.mysql.com/doc/refman/5.1/en/select.html - scroll to comment of June 24 2006.
Sep 13 '06 #2
SET @numrows=5;
PREPARE STMT FROM 'SELECT * FROM tbl LIMIT ?';
EXECUTE STMT USING @numrows;


In this way you can solve your problem.
However if you go to
http://dev.mysql.com/doc/refman/5.1/en/select.html
you can try the same example and a good explanation.
Mar 7 '07 #3

Sign in to post your reply or Sign up for a free account.

Similar topics

7
by: diroddi | last post by:
I am having a problem using a dynamic where clause. I have a feeling that I am overlooking something very simple, although I can't seem to figure it out. The error i'm getting is: You have an...
0
by: Mike Meyer | last post by:
The recent thread on threads caused me to reread the formal definition of SCOOP, and I noticed something I hadn't really impressed me the first time around: it's using staticly checkable rules to...
1
by: Todd Peterson | last post by:
I'm a newbie to DB2 and am trying to figure out how to write a stored procedure, using dynamic SQL statements to return a result set. I believe the majority of the hurdles I have been facing might...
3
by: Ken Varn | last post by:
I have an ASP.NET page that draws over 32 dynamic images using an HttpModule object through the <IMG> tag. Since IIS under Win2K Pro has a limit of 10 connections, some of the images do not get...
24
by: Ken | last post by:
In C programming, I want to know in what situations we should use static memory allocation instead of dynamic memory allocation. My understanding is that static memory allocation like using array...
1
by: satishchandrat | last post by:
Hi, This is regarding the sp_executesql and the sql statement parameter, in processing a dynamic SQL on SQL Server 2000, in my stored procedure. I have my SQL string exeeding more than 4000...
4
by: redoranda | last post by:
hi im a new user here. apparently im working on a project that is creating a dynamic form. Assume user can insert the data into text field and upload csv file, csv file may have two columns. user has...
12
by: hexagram | last post by:
I have a form that calls and generate a dynamic report In that form i have a textbox and a commandbutton In my textbox i enter an ID Formatted like this ('POC-00001') and then i click the...
1
by: renahkw | last post by:
How can I easily limit the amount of rows displayed in a table, and then navigate from page to page? Each row consists of 3 cells: the first, containing a varying number of images followed by some...
0
by: taylorcarr | last post by:
A Canon printer is a smart device known for being advanced, efficient, and reliable. It is designed for home, office, and hybrid workspace use and can also be used for a variety of purposes. However,...
0
by: Charles Arthur | last post by:
How do i turn on java script on a villaon, callus and itel keypad mobile phone
0
by: aa123db | last post by:
Variable and constants Use var or let for variables and const fror constants. Var foo ='bar'; Let foo ='bar';const baz ='bar'; Functions function $name$ ($parameters$) { } ...
0
by: ryjfgjl | last post by:
In our work, we often receive Excel tables with data in the same format. If we want to analyze these data, it can be difficult to analyze them because the data is spread across multiple Excel files...
1
by: nemocccc | last post by:
hello, everyone, I want to develop a software for my android phone for daily needs, any suggestions?
1
by: Sonnysonu | last post by:
This is the data of csv file 1 2 3 1 2 3 1 2 3 1 2 3 2 3 2 3 3 the lengths should be different i have to store the data by column-wise with in the specific length. suppose the i have to...
0
by: Hystou | last post by:
There are some requirements for setting up RAID: 1. The motherboard and BIOS support RAID configuration. 2. The motherboard has 2 or more available SATA protocol SSD/HDD slots (including MSATA, M.2...
0
marktang
by: marktang | last post by:
ONU (Optical Network Unit) is one of the key components for providing high-speed Internet services. Its primary function is to act as an endpoint device located at the user's premises. However,...
0
Oralloy
by: Oralloy | last post by:
Hello folks, I am unable to find appropriate documentation on the type promotion of bit-fields when using the generalised comparison operator "<=>". The problem is that using the GNU compilers,...

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.