<table cellspacing="0" cellpadding="0" border="0" ><tr><td valign="top" style="font: inherit;">It seems that if you specify an empty filter like FILTER "", Mapserver take it instead to ignore it. <br><br>That means Mapserver construct a SQL statement with the WHERE clause empty (without conditionants).<br><br><div><strong><font color="#0000bf">IC Carlos Ruiz</font></strong></div><div><strong><font color="#0000bf"></font></strong> <br></div><br>--- On <b>Wed, 8/6/08, kreshna_iceheart@yahoo.com <i>&lt;kreshna_iceheart@yahoo.com&gt;</i></b> wrote:<br><blockquote style="border-left: 2px solid rgb(16, 16, 255); margin-left: 5px; padding-left: 5px;">From: kreshna_iceheart@yahoo.com &lt;kreshna_iceheart@yahoo.com&gt;<br>Subject: Re: [mapserver-users] Still cannot display postGIS layers using ms4w(MapServer 5.0.2 on WinXP).<br>To: "Kusum" &lt;kusum@infobase.in&gt;<br>Cc: mapserver-users@lists.osgeo.org<br>Date: Wednesday, August 6, 2008, 4:20 AM<br><br><pre>I am
 an idiot.<br><br>Well I don't have a database named postgis on the first place (only<br>template_postgis), but I tried to apply your first DATA line to my own database<br>(test_mapserv).<br><br>Then I realized: your file don't have FILTER "" clause. At the<br>same time, someone from postGIS mailing list told me that an empty FILTER clause<br>will just confuse postGIS. So I remove it from my mapfile and suddenly<br>everything works!<br><br>Thanks,<br>-Kresh<br><br><br>--- On Wed, 8/6/08, Kusum &lt;kusum@infobase.in&gt; wrote:<br><br>&gt; From: Kusum &lt;kusum@infobase.in&gt;<br>&gt; Subject: Re: [mapserver-users] Still cannot display postGIS layers using<br>ms4w(MapServer 5.0.2 on WinXP).<br>&gt; To: kreshna_iceheart@yahoo.com<br>&gt; Date: Wednesday, August 6, 2008, 3:18 AM<br>&gt; Try this format :-<br>&gt; LAYER<br>&gt;   NAME "route"<br>&gt;   STATUS ON<br>&gt;   TYPE line<br>&gt;   CONNECTIONTYPE postgis<br>&gt;   CONNECTION "user=postgres
 dbname=postgis<br>&gt; host=localhost port=5432 <br>&gt; password=postgres"<br>&gt;   DATA "the_geom from ind_road"<br>&gt; #DATA "the_geom from (SELECT the_geom, gid from <br>&gt; shortest_path_as_geometry('hr_road', 1, 50)) as<br>&gt; route using unique gid using <br>&gt; srid=-1"<br>&gt; #DATA "the_geom from (SELECT the_geom from<br>&gt; routing_results) as thing using <br>&gt; unique gid using srid=-1"<br>&gt;  #DATA "the_geom from (SELECT gid, the_geom from<br>&gt; routing_results) as foo <br>&gt; using unique gid using srid=-1"<br>&gt; <br>&gt;  TEMPLATE "t"<br>&gt;   PROJECTION<br>&gt;     "proj=latlong"<br>&gt;     "ellps=WGS84"<br>&gt;      "datum=WGS84"<br>&gt;   END<br>&gt; <br>&gt; --------------------------------------------------<br>&gt; From: &lt;kreshna_iceheart@yahoo.com&gt;<br>&gt; Sent: Wednesday, August 06, 2008 12:40 PM<br>&gt; To: &lt;mapserver-users@lists.osgeo.org&gt;<br>&gt; Subject: [mapserver-users] Still cannot display
 postGIS<br>&gt; layers using <br>&gt; ms4w(MapServer 5.0.2 on WinXP).<br>&gt; <br>&gt; &gt; Help. Somebody please help. Somebody. Anybody. :-(<br>&gt; &gt;<br>&gt; &gt; I am using postgreSQL 8.2.5 for Windows with postGIS.<br>&gt; The database was <br>&gt; &gt; installed using Windows .msi installation package. I<br>&gt; am also using ms4w <br>&gt; &gt; 2.2.7 that comes with MapServer 5.0.2. All installed<br>&gt; on Windows XP Service <br>&gt; &gt; Pack 2.<br>&gt; &gt;<br>&gt; &gt; The MapServer does support postGIS. When I executed<br>&gt; mapserv -v, I got the <br>&gt; &gt; following:<br>&gt; &gt; MapServer version 5.0.2 OUTPUT=GIF OUTPUT=PNG<br>&gt; OUTPUT=JPEG OUTPUT=WBMP <br>&gt; &gt; OUTPUT=PDF OUTPUT=SWF OUTPUT=SVG SUPPORTS=PROJ<br>&gt; SUPPORTS=AGG <br>&gt; &gt; SUPPORTS=FREETYPE SUPPORTS=WMS_SERVER<br>&gt; SUPPORTS=WMS_CLIENT <br>&gt; &gt; SUPPORTS=WFS_SERVER SUPPORTS=WFS_CLIENT<br>&gt; SUPPORTS=WCS_SERVER <br>&gt; &gt; SUPPORTS=SOS_SERVER
 SUPPORTS=FASTCGI SUPPORTS=THREADS<br>&gt; SUPPORTS=GEOS <br>&gt; &gt; INPUT=JPEG INPUT=POSTGIS INPUT=OGR INPUT=GDAL<br>&gt; INPUT=SHAPEFILE<br>&gt; &gt;<br>&gt; &gt; In the postgreSQL database, I have created a database<br>&gt; named test_mapserv. <br>&gt; &gt; I also created a schema named rencana, and a table<br>&gt; named kawasanbencana. <br>&gt; &gt; The name of the geometry column is the_geom.<br>&gt; &gt; I have created a spatial index (kawasanbencanaspix) on<br>&gt; the geometry <br>&gt; &gt; column. I also use lowercase to write the<br>&gt; 'from' statement.<br>&gt; &gt;<br>&gt; &gt; The problem is: MapServer always gives the<br>&gt; "..Query error. Error executing <br>&gt; &gt; POSTGIS DECLARE.." error message, no matter what<br>&gt; I do. And I have tried <br>&gt; &gt; everything ad nauseam.<br>&gt; &gt;<br>&gt; &gt; I have tried specifying the DATA line without USING<br>&gt; UNIQUE ... USING SRID <br>&gt; &gt; line. I have tried specifying
 the DATA line with USING<br>&gt; UNIQUE ...USING <br>&gt; &gt; SRID. I have tried using double apostrophe (")<br>&gt; and single apostrophe ('). <br>&gt; &gt; It doesn't matter. Everything I have tried has<br>&gt; failed, and I still get the <br>&gt; &gt; error message no matter what I did.<br>&gt; &gt;<br>&gt; &gt; My mapfiles are attached in this mail. Each reflect my<br>&gt; futile attempt, and <br>&gt; &gt; all of them generated the error message.<br>&gt; &gt;<br>&gt; &gt;<br>&gt; &gt; My first attempt:<br>&gt; &gt; =================<br>&gt; &gt;<br>&gt; &gt; This is my first attempt. I have both the mapfile and<br>&gt; the error message <br>&gt; &gt; attached on this mail.<br>&gt; &gt;    CONNECTIONTYPE postgis<br>&gt; &gt;    CONNECTION 'host=localhost user=rtrw<br>&gt; password=123456 port=5432 <br>&gt; &gt; dbname=test_mapserver'<br>&gt; &gt;    DATA 'the_geom from rencana.kawasanbencana'<br>&gt; &gt;<br>&gt; &gt; And I got the following error
 message:<br>&gt; &gt; msDrawMap(): Image handling error. Failed to draw<br>&gt; layer named <br>&gt; &gt; 'kawasanbencana'. prepare_database(): Query<br>&gt; error. Error executing POSTGIS <br>&gt; &gt; DECLARE (the actual query) statement: 'DECLARE<br>&gt; mycursor BINARY CURSOR FOR <br>&gt; &gt; SELECT<br>&gt; asbinary(force_collection(force_2d(the_geom)),'NDR'),gid::text<br>&gt; from <br>&gt; &gt; rencana.kawasanbencana WHERE () and (the_geom<br>&gt; &amp;&amp; setSRID( <br>&gt; &gt; 'BOX3D(528635.525378392 9074209,609092.162121608 <br>&gt; &gt;<br>&gt;<br>9134520)'::BOX3D,find_srid('','rencana.kawasanbencana','the_geom')<br>&gt; ))' <br>&gt; &gt; Postgresql reports the error as 'ERROR: syntax<br>&gt; error at or near ")" LINE <br>&gt; &gt; 1: ...DR'),gid::text from rencana.kawasanbencana<br>&gt; WHERE () and (the... ^ ' <br>&gt; &gt; More Help: Error with POSTGIS data variable. You<br>&gt; specified 'check your <br>&gt; &gt; .map file'. Standard
 ways of specifiying are : (1)<br>&gt; 'geometry_column from <br>&gt; &gt; geometry_table' (2) 'geometry_column from (sub<br>&gt; query) as foo using unique <br>&gt; &gt; column name using SRID=srid#' Make sure you put in<br>&gt; the 'using unique <br>&gt; &gt; column name' and 'using SRID=#' clauses<br>&gt; in. For more help, please see<br>&gt; &gt; http://postgis.refractions.net/documentation/<br>&gt; Mappostgis.c - version of <br>&gt; &gt; Jan 23/2004.<br>&gt; &gt;<br>&gt; &gt;<br>&gt; &gt; My second attempt:<br>&gt; &gt; ==================<br>&gt; &gt;<br>&gt; &gt; I tried adding USING UNIQUE to my DATA line. There is<br>&gt; something odd with <br>&gt; &gt; my spatial table though: whenever I view the data<br>&gt; contents with pgAdmin, I <br>&gt; &gt; can always see the oid column. However, I cannot find<br>&gt; the oid column when <br>&gt; &gt; viewing the table's column definition. I attached<br>&gt; the screenshots <br>&gt; &gt; accordingly. The
 question is: does my table have oid<br>&gt; column or not? And <br>&gt; &gt; does it have something to do with the error?<br>&gt; &gt;<br>&gt; &gt; Nonethless, here's my lines:<br>&gt; &gt;    CONNECTIONTYPE postgis<br>&gt; &gt;    CONNECTION 'host=localhost user=rtrw<br>&gt; password=123456 port=5432 <br>&gt; &gt; dbname=test_mapserver'<br>&gt; &gt;    DATA 'the_geom from rencana.kawasanbencana<br>&gt; using unique oid'<br>&gt; &gt;<br>&gt; &gt;<br>&gt; &gt; And I still get the same error message as above. The<br>&gt; difference is that <br>&gt; &gt; the error message now says 'oid' instead of<br>&gt; 'gid'. For instance, <br>&gt; &gt; "(the_geom)),'NDR'),gid" becomes<br>&gt; "(the_geom)),'NDR'),oid", but everything <br>&gt; &gt; else remains the same.<br>&gt; &gt;<br>&gt; &gt;<br>&gt; &gt; My third attempt:<br>&gt; &gt; =================<br>&gt; &gt;<br>&gt; &gt; Like I said in my second attempt, I'm not sure<br>&gt; whether my table has oid <br>&gt;
 &gt; column or not. Thus, in my third attempt I used the<br>&gt; gid column instead, <br>&gt; &gt; especially since the gid column is my primary key<br>&gt; column anyway. This is <br>&gt; &gt; my lines:<br>&gt; &gt;    CONNECTIONTYPE postgis<br>&gt; &gt;    CONNECTION 'host=localhost user=rtrw<br>&gt; password=123456 port=5432 <br>&gt; &gt; dbname=test_mapserver'<br>&gt; &gt;    DATA 'the_geom from rencana.kawasanbencana<br>&gt; using unique gid'<br>&gt; &gt;<br>&gt; &gt; And I got exactly the same error message as my first<br>&gt; attempt.<br>&gt; &gt;<br>&gt; &gt;<br>&gt; &gt; My fourth attempt:<br>&gt; &gt; ==================<br>&gt; &gt;<br>&gt; &gt; In my fourth attempt, I used the gid column for my<br>&gt; unique id, and I am <br>&gt; &gt; using SRID=1. Here is the lines:<br>&gt; &gt;    CONNECTIONTYPE postgis<br>&gt; &gt;    CONNECTION 'host=localhost user=rtrw<br>&gt; password=123456 port=5432 <br>&gt; &gt; dbname=test_mapserver'<br>&gt; &gt;  
  DATA 'the_geom from rencana.kawasanbencana<br>&gt; using unique gid using <br>&gt; &gt; SRID=1'<br>&gt; &gt;<br>&gt; &gt; Well I still got the error message. This time, the<br>&gt; error message is <br>&gt; &gt; slightly different. Instead of getting<br>&gt; "::BOX3D,find_srid", I got <br>&gt; &gt; "::BOX3D,1".<br>&gt; &gt;<br>&gt; &gt; Here is the complete error message:<br>&gt; &gt; msDrawMap(): Image handling error. Failed to draw<br>&gt; layer named <br>&gt; &gt; 'kawasanbencana'. prepare_database(): Query<br>&gt; error. Error executing POSTGIS <br>&gt; &gt; DECLARE (the actual query) statement: 'DECLARE<br>&gt; mycursor BINARY CURSOR FOR <br>&gt; &gt; SELECT<br>&gt; asbinary(force_collection(force_2d(the_geom)),'NDR'),gid::text<br>&gt; from <br>&gt; &gt; rencana.kawasanbencana WHERE () and (the_geom<br>&gt; &amp;&amp; setSRID( <br>&gt; &gt; 'BOX3D(528635.525378392 9074209,609092.162121608<br>&gt; 9134520)'::BOX3D,1) )' <br>&gt; &gt; Postgresql
 reports the error as 'ERROR: syntax<br>&gt; error at or near ")" LINE <br>&gt; &gt; 1: ...DR'),gid::text from rencana.kawasanbencana<br>&gt; WHERE () and (the... ^ ' <br>&gt; &gt; More Help: Error with POSTGIS data variable. You<br>&gt; specified 'check your <br>&gt; &gt; .map file'. Standard ways of specifiying are : (1)<br>&gt; 'geometry_column from <br>&gt; &gt; geometry_table' (2) 'geometry_column from (sub<br>&gt; query) as foo using unique <br>&gt; &gt; column name using SRID=srid#' Make sure you put in<br>&gt; the 'using unique <br>&gt; &gt; column name' and 'using SRID=#' clauses<br>&gt; in. For more help, please see <br>&gt; &gt; http://postgis.refractions.net/documentation/<br>&gt; &gt; Mappostgis.c - version of Jan 23/2004.<br>&gt; &gt;<br>&gt; &gt;<br>&gt; &gt; My fifth attempt:<br>&gt; &gt; =================<br>&gt; &gt;<br>&gt; &gt; Now I had been pretty much desperate, I just wrote<br>&gt; using SRID=#, closed my <br>&gt; &gt; eyes, and
 hoped for the best. Here's the lines:<br>&gt; &gt;    CONNECTIONTYPE postgis<br>&gt; &gt;    CONNECTION 'host=localhost user=rtrw<br>&gt; password=123456 port=5432 <br>&gt; &gt; dbname=test_mapserver'<br>&gt; &gt;    DATA 'the_geom from rencana.kawasanbencana<br>&gt; using unique gid using <br>&gt; &gt; SRID=#'<br>&gt; &gt;<br>&gt; &gt; I still get an error message. This time, the error<br>&gt; message is different <br>&gt; &gt; altogether. Here's the message:<br>&gt; &gt; msDrawMap(): Image handling error. Failed to draw<br>&gt; layer named <br>&gt; &gt; 'kawasanbencana'. msPOSTGISLayerParseData():<br>&gt; Query error. Error parsing <br>&gt; &gt; POSTGIS data variable: You specified 'using<br>&gt; SRID=#' but didnt have any <br>&gt; &gt; numbers! More Help: Error with POSTGIS data variable.<br>&gt; You specified <br>&gt; &gt; 'the_geom from rencana.kawasanbencana using unique<br>&gt; gid using SRID=#'. <br>&gt; &gt; Standard ways of specifiying are :
 (1)<br>&gt; 'geometry_column from <br>&gt; &gt; geometry_table' (2) 'geometry_column from (sub<br>&gt; query) as foo using unique <br>&gt; &gt; column name using SRID=srid#' Make sure you put in<br>&gt; the 'using unique <br>&gt; &gt; column name' and 'using SRID=#' clauses<br>&gt; in. For more help, please see <br>&gt; &gt; http://postgis.refractions.net/documentation/<br>&gt; Mappostgis.c - version of <br>&gt; &gt; Jan 23/2004.<br>&gt; &gt;<br>&gt; &gt;<br>&gt; &gt; I'm pretty much desperate. Could somebody please<br>&gt; tell what's wrong on my <br>&gt; &gt; mapfile? Or maybe ms4w just cannot display postGIS<br>&gt; data? Do I need to <br>&gt; &gt; install postGIS and MapServer on Linux, in order to<br>&gt; get them work <br>&gt; &gt; together? Please help. :-(<br>&gt; &gt;<br>&gt; &gt;<br>&gt; &gt; Thanks,<br>&gt; &gt; -Kresh<br>&gt; &gt;<br>&gt; &gt;<br>&gt; &gt;<br>&gt; &gt;<br>&gt; <br>&gt; <br>&gt; <br>&gt; &gt;
 _______________________________________________<br>&gt; &gt; mapserver-users mailing list<br>&gt; &gt; mapserver-users@lists.osgeo.org<br>&gt; &gt;<br>&gt; http://lists.osgeo.org/mailman/listinfo/mapserver-users<br>&gt; &gt;<br><br><br>      <br>_______________________________________________<br>mapserver-users mailing list<br>mapserver-users@lists.osgeo.org<br>http://lists.osgeo.org/mailman/listinfo/mapserver-users<br></pre></blockquote></td></tr></table><br>