I have trouble with a filter expression for a PostGIS DB on the fly with mapscript. <br><br>If I define the filter in the mapfile it works fine, eg.<br>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; FILTER &quot;nmlocal like 'Deqin xian'&quot;<br>MapServer recognises the quotes around the string expression for 'like' and returns the correct result.
<br><br>However, I need to create this filter on the fly with mapscript (I want a user to supply the string to match), so on my layer I do a <br>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; layer.setFilter(&quot;nmlocal like 'Deqin'&quot;)<br><br>This has the effect that mapserver recognises the quote that begin the 'Deqin' string as the end of the filter, resulting in a syntactically incorrect SQL expression. I have tried various quoting formats (backslashed-escaped, even $ and $$ quoting), all with the same result:
<br><br>prepare_database(): Query error. Error executing POSTGIS DECLARE (the actual query) statement: &amp;#39;DECLARE mycursor BINARY CURSOR FOR SELECT asbinary(force_collection(force_2d(the_geom)),&amp;#39;NDR&amp;#39;),OID::text from yunnancounties_poly WHERE (nmlocal like ) and (the_geom &amp;amp;&amp;amp; setSRID( &amp;#39;BOX3D(97 20,
106.5 29.5)&amp;#39;::BOX3D,find_srid(&amp;#39;&amp;#39;,&amp;#39;yunnancounties_poly&amp;#39;,&amp;#39;the_geom&amp;#39;) ))&amp;#39;<br><br>Any idea or suggestion?<br><br>Ludwig<br><br>