Error on Itemnquery with PostGIS-layer

Umberto Nicoletti umberto.nicoletti at GMAIL.COM
Wed Aug 22 03:09:21 EDT 2007


> http://myServer.com/cgi-bin/Hybrid?&map=/home/Harry/Mapfile/MyMap.map&mode=itemnquery&qlayer=City-Database&qitem='name.name'&qstring='London'
>
> what causes this error on a Debian Linux machine with Mapserver 4.8.3:
>
> prepare_database(): Query error. Error executing POSTGIS DECLARE (the actual
> query) statement: 'DECLARE mycursor BINARY CURSOR FOR SELECT
> 'name.name'::text,asbinary(force_collection(force_2d(the_geom)),'NDR'),gid::text
> from name WHERE (London) and (the_geom && setSRID( 'BOX3D(-180 -90,180
> 90)'::BOX3D,find_srid('','name','the_geom') ))'
>

Please open up your favourite sql interface to postgres and then paste
the query excerpt from above:

SELECT
'name.name'::text,
asbinary(force_collection(force_2d(the_geom)),'NDR'),
gid::text
from
name
WHERE
(London) and
(the_geom && setSRID(
'BOX3D(-180-90,18090)'::BOX3D,find_srid('','name','the_geom') ))'

if you look closely at it you'll see that the first where clause
(London) is written wrong. You the have to modify qstring so that it
produces a valid where clause like this:

name='London'

so that the query is written as follows:

SELECT
'name.name'::text,
asbinary(force_collection(force_2d(the_geom)),'NDR'),
gid::text
from
name
WHERE
name='London' and
(the_geom && setSRID(
'BOX3D(-180-90,18090)'::BOX3D,find_srid('','name','the_geom') ))'

then run in the query in the sql client and see if it works. If it
does you can try it in mapserver.
I think that for sql-based layers the qstring MUST be a valid where
clause and not only a value to be matched against qitem. In this
respect SQL layers differ sifferently from shapefiles based layers.

Regards,
Umberto



More information about the mapserver-users mailing list