Z SQL Methods and the SQL LIMIT clause
Is there a reason why Z SQL methods do not allow the use of the LIMIT clause? I am absolutely certain that my query has the right syntax since I executed it against the MySQL server and it gave me the correct results. FYI, I have provided the query below: SELECT course_id FROM course WHERE course_id < 991000 ORDER BY course_id DESC LIMIT 1 Furthermore, Zope throws the following error when I try to test this query via the ZMI and also when I use it in my application: (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 'LIMIT 1000' at line 3") Any help would be appreciated. Thank you. - Asad
On 5/11/05, Asad Habib <ahabib@engin.umich.edu> wrote:
Is there a reason why Z SQL methods do not allow the use of the LIMIT clause? I am absolutely certain that my query has the right syntax since I executed it against the MySQL server and it gave me the correct results. FYI, I have provided the query below:
SELECT course_id FROM course WHERE course_id < 991000 ORDER BY course_id DESC LIMIT 1
Furthermore, Zope throws the following error when I try to test this query via the ZMI and also when I use it in my application:
(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 'LIMIT 1000' at line 3")
LIMIT is not a standard SQL clause. ZMySQLDA uses it internally, based upon the max_row properties of the Z SQL Method. If you want to use it, get rid of the LIMIT clause in your query, and set the max_rows property accordingly. Also, you can "trick" ZMySQLDA into not adding a LIMIT by putting a comment before your SQL statement. http://www.zope.org/Members/adustman/Tips/no_limits -- Computer interfaces should never be made of meat. http://www.terrybisson.com/meat.html
Assuming MySQL, I found the fix for this was to go the Advanced tab for the ZSQL Method (in the ZMI) and set "Maximum Rows to Retrieve" to zero. After that, my limit clause worked without a problem. On 5/11/05, Asad Habib <ahabib@engin.umich.edu> wrote:
Is there a reason why Z SQL methods do not allow the use of the LIMIT clause? I am absolutely certain that my query has the right syntax since I executed it against the MySQL server and it gave me the correct results. FYI, I have provided the query below:
SELECT course_id FROM course WHERE course_id < 991000 ORDER BY course_id DESC LIMIT 1
Furthermore, Zope throws the following error when I try to test this query via the ZMI and also when I use it in my application:
(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 'LIMIT 1000' at line 3")
Any help would be appreciated. Thank you.
- Asad _______________________________________________ Zope maillist - Zope@zope.org http://mail.zope.org/mailman/listinfo/zope ** No cross posts or HTML encoding! ** (Related lists - http://mail.zope.org/mailman/listinfo/zope-announce http://mail.zope.org/mailman/listinfo/zope-dev )
participants (3)
-
Andy Dustman -
Asad Habib -
Garth B.