Postgis filter trouble with quotes
Ludwig Max Brinckmann
ludwigbrinckmann at GMAIL.COM
Sun Oct 15 09:12:41 PDT 2006
I have trouble with a filter expression for a PostGIS DB on the fly with
mapscript.
If I define the filter in the mapfile it works fine, eg.
FILTER "nmlocal like 'Deqin xian'"
MapServer recognises the quotes around the string expression for 'like' and
returns the correct result.
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
layer.setFilter("nmlocal like 'Deqin'")
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:
prepare_database(): Query error. Error executing POSTGIS DECLARE (the actual
query) statement: 'DECLARE mycursor BINARY CURSOR FOR SELECT
asbinary(force_collection(force_2d(the_geom)),'NDR'),OID::text from
yunnancounties_poly WHERE (nmlocal like ) and (the_geom && setSRID(
'BOX3D(97 20,106.5
29.5)'::BOX3D,find_srid('','yunnancounties_poly','the_geom')
))'
Any idea or suggestion?
Ludwig
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://lists.osgeo.org/pipermail/mapserver-users/attachments/20061015/cdf85754/attachment.htm>
More information about the MapServer-users
mailing list