<div dir="ltr"><div><div><div>Assuming that you haven't resolved this yet, I would try creating a table from your view and using that in your map file. This won't fix the issue but might help you isolate it. So in psql:<br>
</div>    CREATE TABLE test AS SELECT * FROM <span style="font-size:9pt;font-family:'Verdana','sans-serif'"><span style="color:rgb(0,50,100)"><span><font color="#000080" face="Arial">xy.test;<br></font></span></span></span></div>
and in your map file:<br>  DATA "geom from test using unique gid using SRID=4269"<br></div>(I removed the sub-select to keep it as simple as possible).<br><br>Rich<br><div><br><br></div></div><div class="gmail_extra">
<br><br><div class="gmail_quote">On Wed, Jul 24, 2013 at 10:55 AM, karsten <span dir="ltr"><<a href="mailto:karsten@terragis.net" target="_blank">karsten@terragis.net</a>></span> wrote:<br><blockquote class="gmail_quote" style="margin:0 0 0 .8ex;border-left:1px #ccc solid;padding-left:1ex">
<u></u>



<div>
<div dir="ltr" align="left"><span><font color="#000080" face="Arial">Yes the view does have the gid (I did not include all the 
fields of the view and stupidly forgit to t list the gid field in the 
email) below. I tried to use a different colum as unique key and select it AS 
gid instead which did not work (same error), then I added a new unique id 
using</font></span></div>
<div dir="ltr" align="left"><span><font color="#000080" face="Arial">nextval('myloc_loc_gid_seq'::regclass) AS gid (and omitted the 
old one), </font></span></div>
<div dir="ltr" align="left"><span><font color="#000080" face="Arial">still same error.</font></span></div>
<div dir="ltr" align="left"><span><font color="#000080" face="Arial">what else should, itry - running  out of ideas 
</font></span></div>
<div dir="ltr" align="left"><span></span> </div>
<div dir="ltr" align="left"><span><font color="#000080" face="Arial">Cheers</font></span></div>
<div dir="ltr" align="left"><span><font color="#000080" face="Arial">Karsten</font></span></div>
<div dir="ltr" align="left"><span><font color="#000080" face="Arial"></font></span> </div>
<div dir="ltr" align="left" lang="en-us">
<hr>
<font face="Tahoma"><b>From:</b> Richard Greenwood 
[mailto:<a href="mailto:richard.greenwood@gmail.com" target="_blank">richard.greenwood@gmail.com</a>] <br><b>Sent:</b> Wednesday, July 24, 2013 
07:05 AM<br><b>To:</b> <a href="mailto:karsten@terragis.net" target="_blank">karsten@terragis.net</a>; PostGIS Users 
Discussion<br><b>Cc:</b> PostGIS Users Discussion<br><b>Subject:</b> Re: 
[postgis-users] PostGIS 2.02 view problem<br></font><br></div><div><div class="h5">
<div></div>
<div dir="ltr">In your map file you have "<span style="FONT-SIZE:9pt;FONT-FAMILY:'Verdana','sans-serif'"><span style="COLOR:rgb(0,50,100)"><span><font color="#000080" face="Arial">using unique 
gid". Are you sure that there is a "gid" column in your 
view?<br><br>Rich<br></font></span></span></span></div>
<div class="gmail_extra"><br><br>
<div class="gmail_quote">On Wed, Jul 24, 2013 at 3:35 AM, karsten <span dir="ltr"><<a href="mailto:karsten@terragis.net" target="_blank">karsten@terragis.net</a>></span> wrote:<br>
<blockquote class="gmail_quote" style="PADDING-LEFT:1ex;MARGIN:0px 0px 0px 0.8ex;BORDER-LEFT:#ccc 1px solid"><u></u>
  <div>
  <div><span><font color="#000080" face="Arial">Hi all,</font></span></div>
  <div><span><font color="#000080" face="Arial"></font></span> </div>
  <div><span><font color="#000080" face="Arial">I am trying to use a b view in 
  Postgis 2.0.2 ("POSTGIS="2.0.2 r10789" GEOS="3.3.8-CAPI-1.7.8" PROJ="Rel. 
  4.8.0, 6 March 2012" GDAL="GDAL 1.10.0, released 2013/04/24" LIBXML="2.8.0" 
  LIBJSON="UNKNOWN" TOPOLOGY RASTER")</font></span></div>
  <div><span><font color="#000080" face="Arial">for display via MapServer 6.2 
  </font></span></div>
  <div><span><font color="#000080" face="Arial">I am getting an this error from 
  MapServer:</font></span></div>
  <div><span><font color="#000080" face="Arial"></font></span> </div>
  <div><span><font color="#000080" face="Arial">Failed to draw layer named 
  &#39;members&#39;.<br>msPostGISLayerWhichShapes(): Query error. Error 
  executing query: ERROR:  column &quot;COUNT&quot; does not 
  exist<br>LINE 1: select 
  &quot;COUNT&quot;,encode(ST_AsBinary(ST_Force_2D(&quot;geom&quot;),&#39;NDR&#39;).</font></span></div>
  <div><font color="#000080" face="Arial"></font> </div>
  <div><span><font color="#000080" face="Arial">I have no idea why a count is needed 
  here or where this field is coming from ...seems that the regular table have 
  no issue with this. </font></span></div>
  <div><span><font color="#000080" face="Arial"></font></span> </div>
  <div><span><font color="#000080" face="Arial">My VIEW 
  public.geometry_columns  shows these values for the 
  view:</font></span></div>
  <div><span><font color="#000080" face="Arial">"xy";"xy";"myloc";"geom";2;4269;"POINT"</font></span></div>
  <div><span><font color="#000080" face="Arial"></font></span> </div>
  <div><span><font color="#000080" face="Arial">What can I do to fix this in 
  Postgis ?</font></span></div>
  <div><span><font color="#000080" face="Arial">See below for view 
  details</font></span></div>
  <div><span><font color="#000080" face="Arial"></font></span> </div>
  <div><span><font color="#000080" face="Arial">Cheers</font></span></div>
  <div><span><font color="#000080" face="Arial">Karsten</font></span></div><span style="FONT-SIZE:9pt;FONT-FAMILY:'Verdana','sans-serif'">
  <div><br><span style="COLOR:#003264">Terra GIS LTD<br></span></div>
  <div><span style="COLOR:#003264"><span>-------------------------</span></span></div>
  <div><span style="COLOR:#003264"><span>-- View: </span></span></div>
  <div><span style="COLOR:#003264"><span><font color="#000080" face="Arial">CREATE 
  OR REPLACE VIEW xy.test 
  AS                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                          <br>
 SELECT 
  xy.census_city_id, st_centroid(places.geom)::geometry(Point,4269) AS geom, <a href="http://places.name" target="_blank">places.name</a><br>   FROM 
  myschema.xy,myschema.places                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                <br>
  WHERE xy.census_city_id = 
  places.geoid::integer;                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                              
  <br>ALTER TABLE 
  myschema.xy_loc                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                         <br>
<br>OWNER TO 
  myuser;     </font></span></span></div>
  <div><span style="COLOR:#003264"><span><font color="#000080" face="Arial"></font></span></span> </div>
  <div><span style="COLOR:#003264"><span><font color="#000080" face="Arial">-----------------------------------</font></span></span></div>
  <div><span style="COLOR:#003264"><span><font color="#000080" face="Arial">in 
  mapfile:</font></span></span></div>
  <div><span style="COLOR:#003264"><span><font color="#000080" face="Arial"><br>DATA "geom from (select * from myschema.xy) as temp using 
  unique gid using SRID=4269"  
  </font></span></span></div></span></div><br>_______________________________________________<br>postgis-users 
  mailing list<br><a href="mailto:postgis-users@lists.osgeo.org" target="_blank">postgis-users@lists.osgeo.org</a><br><a href="http://lists.osgeo.org/cgi-bin/mailman/listinfo/postgis-users" target="_blank">http://lists.osgeo.org/cgi-bin/mailman/listinfo/postgis-users</a><br>
<br></blockquote></div><br><br clear="all"><br>-- <br>Richard Greenwood<br><a href="mailto:richard.greenwood@gmail.com" target="_blank">richard.greenwood@gmail.com</a><br><a href="http://www.greenwoodmap.com" target="_blank">www.greenwoodmap.com</a> </div>
</div></div></div>
</blockquote></div><br><br clear="all"><br>-- <br>Richard Greenwood<br><a href="mailto:richard.greenwood@gmail.com">richard.greenwood@gmail.com</a><br><a href="http://www.greenwoodmap.com">www.greenwoodmap.com</a>
</div>