Simple query using ZMySQLDA => (1064, "You have an error in your SQL syntax near ' LIMIT 1000' at line 2")
I'm trying to use a very simple SQL query against a MySQL database, a sql-method called sqlViewMovieReview taking one parameter emr_id, an integer-value: select * from elope_moviereviews where emr_id = <dtml-var emr_id><dtml-var sql_delimiter> It works great then tested in the ZMI-test interface, but fails when used in a page, like when i test it like so : http://localhost:8080/MovieReviews/dmMovieReviewDetails?emr_id=4 Error reported : (1064, "You have an error in your SQL syntax near ' LIMIT 1000' at line 2") The DTML Method used over : <dtml-with expr="sqlViewMovieReview(emr_id='<dtml-var emr_id>')"> <dtml-var title> </dtml-with> Looked around on the net and found some references to the error, for instance http://linux.bryanconsulting.com/stories/storyReader$75. Added the <dtml-var sql_delimiter> but the error is still there. I'm using Zope 2.5.1 and ZMySQLDA 2.0.9. Any clues ?? Best regards, Thomas Weholt
Thomas Weholt writes:
... <dtml-with expr="sqlViewMovieReview(emr_id='<dtml-var emr_id>')"> <dtml-var title> </dtml-with> A standard error. It happened thousand of times...
You pass the literal string '<dtml-var emr_id>' to your Z SQL method. This gives a funny SQL statement. Use "emr_id=emr_id" instead to pass the value of "emr_id". You said "emr_id" should be an integer? Then, you should either use "emr_id:int=..." in your query string (or as form variable name) or "emr_id=_.int(emr_id)" to convert the string into an integer. Dieter
participants (2)
-
Dieter Maurer -
Thomas Weholt