[Zope] Re: Simple query using ZMySQLDA => (1064, "You have an error in your SQL syntax near ' LIMIT 1000' at line 2")

Dennis Allison allison@sumeru.stanford.EDU
Sat, 13 Jul 2002 07:26:27 -0700


> From: "Egon Frerich" <e.frerich@nord-com.net>
> > To: <zope@zope.org>
> > Date: Thu, 11 Jul 2002 23:50:46 +0200
> > Subject: [Zope] 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>
> 
> Did you try?
> where emr_id = <dtml-sqlvar emr_id type="int">
> 

You'd be better off using 

where <dtml-sqltest name="emr_id" column_name="XXX" type="string">

in your query to get the proper quoting, etc.  XXX should be replaced by 
the name of the column you are testing against the parameter "emr_id" and 
the type should correspond.  There are additonal attributes you can set.
This one relies on the default comparison, equality.