[postgis-users] MapServer subquery problem

Geodata Analysis info at e-geodata.gr
Mon Aug 29 03:50:29 PDT 2005


Hi List,

I'm trying to add a layer from postgis in my mapfile but i get the 
following error :

*Warning*: [MapServer Error]: prepare_database(): Error executing 
POSTGIS DECLARE (the actual query) statement: 'DECLARE mycursor BINARY 
CURSOR FOR SELECT asbinary(force_collection(force_2d(the_geom 
from(SELECT table1.the_geom AS the_geom)),'NDR'),gid::text from table1, 
table2 WHERE distance(table1.the_geom, table2.the_geom) < 1000) as foo 
WHERE the_geom from(SELECT table1.the_geom AS the_geom && 
setSRID('BOX3D(742438.212 4108421.689,759685.98 4121357.515)'::BOX3D, -1 )'

Postgresql reports the error as 'ERROR: syntax error at or near "from" 
at character 87 '

the line in my mapfile is :
DATA        "the_geom from(SELECT table1.the_geom AS the_geom FROM 
table1, table2 WHERE distance(table1.the_geom, table2.the_geom) < 1000) 
as foo using unique gid using srid=-1"

1. I've tried a lot variations
2. If I declare the layer without the subquery, all the data is 
displayed correctly.
3. If I execute the query : select the_geom from(SELECT table1.the_geom 
AS the_geom FROM table1, table2 WHERE distance(table1.the_geom, 
table2.the_geom) < 1000) as foo in phppgadmin, I get the correct results

Any ideas ?
Thank you

Stathis Stergou
Gis Programmer





More information about the postgis-users mailing list