Click here to Skip to main content
15,881,600 members
Please Sign up or sign in to vote.
5.00/5 (1 vote)
SQL
CREATE  PROCEDURE `FetchSupplierByRequest`(intConferenceId int, intRank int,intTableNo int)
BEGIN
SELECT Distinct
c.ID ,
  c.CompanyName,
c.Type
FROM
  conferencetabletop cp,
  companies c,
meeting m
WHERE
  cp.ConferenceID = intConferenceId
    AND
  c.ID = m.SupplierID
and m.AgendaID=cp.ConferenceId
and m.Rank=intRank
ORDER BY
  m.CreatedDate DESC
LIMIT 0, intTableNo;
END



showing the error when its upload in server .

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 'intTableNo' at line 19
Posted
Comments
Rajib Mahata 21-Jan-14 1:39am    
but if i check the select query in server then it works .
SELECT DISTINCT c.ID, c.CompanyName, c.Type
FROM conferencetabletop cp, companies c, meeting m
WHERE cp.ConferenceID =21
AND c.ID = m.SupplierID
AND m.AgendaID = cp.ConferenceId
AND m.Rank =1
ORDER BY m.CreatedDate DESC
LIMIT 0,10;
idenizeni 21-Jan-14 17:27pm    
Are you missing a statement delimiter after the END keyword? Should the last line be END;
Rajib Mahata 22-Jan-14 4:16am    
i added delimiter but shown same error .
idenizeni 22-Jan-14 17:45pm    
I just saw your reply. If you use the Reply on a comment then a message gets sent to the poster. As for your question; from what I can tell it looks like the issue may be related to the fact that LIMIT cannot be parameterized in MySQL. So, it works in your test because you are using literal values in the LIMIT clause.
Rajib Mahata 22-Jan-14 5:37am    
when i run
SELECT DISTINCT c.ID, c.CompanyName, c.Type
FROM conferencetabletop AS cp, companies AS c, meeting AS m
WHERE cp.ConferenceID =21
AND c.ID = m.SupplierID
AND m.AgendaID = cp.ConferenceID
AND m.Rank =1
ORDER BY m.CreatedDate DESC
LIMIT 0 , 12

its return value .

1 solution

According to the information I can find, older versions of MySQL cannot use variables in the LIMIT clause and constants must be used.

Similar issue posted to StackOverflow with some useful information.

http://stackoverflow.com/questions/2875238/passing-limit-as-parameters-to-mysql-sproc[^]
 
Share this answer
 
Comments
Rajib Mahata 3-Feb-14 5:39am    
Thanks For Answer

This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)

  Print Answers RSS
Top Experts
Last 24hrsThis month


CodeProject, 20 Bay Street, 11th Floor Toronto, Ontario, Canada M5J 2N8 +1 (416) 849-8900