If you imported the spatial layer with shp2pgsql or OGR programs, their should be a unique id field already (e.g. 'gid' with shp2pgsql). You can tell MapServer to use this unique id field instead of oid in the LAYER -> DATA variable of your MapFile.
<br><br>Example:<br>&nbsp;&nbsp;&nbsp;&nbsp; DATA &quot;the_geom FROM roads AS foo USING UNIQUE gid&quot;<br><br>Aaron<br><br><br><div><span class="gmail_quote">On 6/22/06, <b class="gmail_sendername">Nigel Gilbert</b> &lt;<a href="mailto:n.gilbert@surrey.ac.uk">
n.gilbert@surrey.ac.uk</a>&gt; wrote:</span><blockquote class="gmail_quote" style="border-left: 1px solid rgb(204, 204, 204); margin: 0pt 0pt 0pt 0.8ex; padding-left: 1ex;">I am trying to use mapserver with a PostGIS enabled database.&nbsp;&nbsp;However, I
<br>get the mapserver error:<br><br>prepare_database(): Query error. Error executing POSTGIS DECLARE (the actual<br>query) statement: 'DECLARE mycursor BINARY CURSOR FOR SELECT<br>asbinary(force_collection(force_2d(geom)),'XDR'),OID::text from world WHERE
<br>geom &amp;&amp; setSRID('BOX3D(-1333.33333333333 -1000,1333.33333333333<br>1000)'::BOX3D, find_srid('','world','geom') )'<br><br>Postgresql reports the error as 'ERROR: column &quot;oid&quot; does not exist '<br><br>I then noticed that the documentation for PostGIS, section 
4.7.1 says that I<br>should create an oid index for the table I am wanting to display.&nbsp;&nbsp;So,<br>following the suggestion there, I tried, in the psql monitor:<br><br>create index world_oid_index on world ( oid );<br>ERROR:&nbsp;&nbsp;column &quot;oid&quot; does not exist
<br><br>where 'world' is the table containing my geometry column.&nbsp;&nbsp;I haven't found<br>anything useful to help in either the PostGIS documenation or the PostgreSQL<br>docs.<br><br>What am I doing wrong?<br><br>Many thanks for your help!
<br><br><br>--<br>Nigel<br></blockquote></div><br><br clear="all"><br>-- <br>+--------------------------------------------<br>|&nbsp;&nbsp;Aaron Koning<br>|&nbsp;&nbsp;Information Technologist<br>|&nbsp;&nbsp;Prince George, BC, Canada.<br>+--------------------------------------------
<br>|&nbsp;&nbsp;<a href="http://datashare.gis.unbc.ca/fist/">http://datashare.gis.unbc.ca/fist/</a><br>|&nbsp;&nbsp;<a href="http://datashare.gis.unbc.ca/gctp-js/">http://datashare.gis.unbc.ca/gctp-js/</a><br>+--------------------------------------------