<table cellspacing="0" cellpadding="0" border="0" ><tr><td valign="top" style="font: inherit;">I see what Ben was worried about and what you're trying to do. I haven't done a lot of variable substitution but I have done a lot of head scratching to when queries don't work as expected. A couple things that might shed some light you could try:<br><br>"like '%spp%'" &nbsp;&nbsp; and&nbsp; pass &amp;spp=%TAR%<br><br>If you're looking for a string containing TAR.&nbsp; It might confirm that the double %% are being misinterpreted. <br><br>Or you could try if this is the case and you want to force the wildcards at the mapfile level. <br>"like '%' || '%spp%' || '%"'<br><br>Josh<br><br>--- On <b>Sun, 3/14/10, pcreso@pcreso.com <i>&lt;pcreso@pcreso.com&gt;</i></b> wrote:<br><blockquote style="border-left: 2px solid rgb(16, 16, 255); margin-left: 5px; padding-left: 5px;"><br>From: pcreso@pcreso.com &lt;pcreso@pcreso.com&gt;<br>Subject: Re: [mapserver-users] runtime
 substitution not working<br>To: mapserver-users@lists.osgeo.org<br>Date: Sunday, March 14, 2010, 1:29 PM<br><br><div class="plainMail"><br>Hi Ben...<br><br>I have it working in other setups fine - just this one won't behave.<br><br>If I use "like '%spp%'" &amp; pass &amp;spp=TAR, then the query that gets run is<br>"like 'TAR', which is basically an un-indexed =<br><br>I need a "like '%TAR%'" in the SQL hence the double % sign. I have this working elsewhere fine (but with different versions of mapserver &amp; Postgis)<br><br>Capitalisation might be the problem... I'll try that...<br><br><br>Thanks,<br><br>&nbsp;&nbsp;&nbsp;Brent<br> <br><br>--- On Sun, 3/14/10, Ben Madin &lt;<a ymailto="mailto:lists@remoteinformation.com.au" href="/mc/compose?to=lists@remoteinformation.com.au">lists@remoteinformation.com.au</a>&gt; wrote:<br><br>&gt; From: Ben Madin &lt;<a ymailto="mailto:lists@remoteinformation.com.au"
 href="/mc/compose?to=lists@remoteinformation.com.au">lists@remoteinformation.com.au</a>&gt;<br>&gt; Subject: Re: [mapserver-users] runtime substitution not working<br>&gt; To: <a ymailto="mailto:mapserver-users@lists.osgeo.org" href="/mc/compose?to=mapserver-users@lists.osgeo.org">mapserver-users@lists.osgeo.org</a><br>&gt; Cc: <a ymailto="mailto:pcreso@pcreso.com" href="/mc/compose?to=pcreso@pcreso.com">pcreso@pcreso.com</a><br>&gt; Date: Sunday, March 14, 2010, 1:25 PM<br>&gt; G'day Brent,<br>&gt;<br>&gt; It might not matter, but you have double %% in the DATA<br>&gt; statement you have passed,<br>&gt;<br>&gt; and for whatever reason - I recevied advice from this list<br>&gt; or OpenLayers list - I have all my variable names<br>&gt; capitalised in the query:<br>&gt;<br>&gt;&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; <br>&gt;&nbsp; &nbsp; &nbsp; &nbsp;&nbsp;&nbsp;WHERE transferdate<br>&gt; &gt;= '%STARTDATE%' AND transferdate &lt;=
 '%ENDDATE%'<br>&gt;&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; <br>&gt;&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp;&nbsp;&nbsp;AND<br>&gt; line_geom IS NOT NULL<br>&gt;&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; <br>&gt;&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp;&nbsp;&nbsp;AND<br>&gt; sourceshire NOT LIKE destinationshire<br>&gt;&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; <br>&gt;&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp;&nbsp;&nbsp;AND<br>&gt; sourceshire LIKE '%SOURCESHIRE%'<br>&gt;<br>&gt; So I hope these might help if Steve's solution didn't<br>&gt;<br>&gt; cheers<br>&gt;<br>&gt; Ben<br>&gt;<br>&gt;<br>&gt;<br>&gt; On 13/03/2010, at 24:00 , <a ymailto="mailto:mapserver-users-request@lists.osgeo.org" href="/mc/compose?to=mapserver-users-request@lists.osgeo.org">mapserver-users-request@lists.osgeo.org</a><br>&gt; wrote:<br>&gt;<br>&gt; &gt; I'm obviously doing something wrong, but can't see<br>&gt; what it is... I have a Postgis table of species
 occurences<br>&gt; &amp; I want to pass a variable to the mapfile to select<br>&gt; which speciesusing runtime substitution.<br>&gt; &gt;<br>&gt; &gt; The relevant DATA statement (joining species in the<br>&gt; catch to locations in the station) in the mapfile is:<br>&gt; &gt;<br>&gt; &gt; DATA "startp from (select c.id, s.startp, s.trip_code,<br>&gt;<br>&gt; &gt;&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp;&nbsp;&nbsp;<br>&gt;&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; <br>&gt; s.station_no, c.species,<br>&gt; &gt;&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp;&nbsp;&nbsp;<br>&gt;&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp;&nbsp;&nbsp;c.weight<br>&gt; &gt;&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp;&nbsp;&nbsp;<br>&gt;&nbsp; &nbsp; &nbsp; &nbsp; from t_station s, catch c<br>&gt; &gt;&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp;&nbsp;&nbsp;<br>&gt;&nbsp; &nbsp; &nbsp; &nbsp; where<br>&gt; s.station_no=c.station_no<br>&gt; &gt;&nbsp;
 &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp;&nbsp;&nbsp;<br>&gt;&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; and c.species ilike<br>&gt; '%%spp%%')<br>&gt; &gt;&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp;&nbsp;&nbsp;<br>&gt;&nbsp; &nbsp; &nbsp; &nbsp; as myquery<br>&gt; &gt;&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp;&nbsp;&nbsp;<br>&gt;&nbsp; &nbsp; &nbsp; &nbsp; using unique id using<br>&gt; srid=4326"<br>&gt; &gt;<br>&gt; &gt;<br>&gt; &gt; The query works in Postgis &amp; in the mapfile (via<br>&gt; QGIS) when I hard code the %spp% (eg, to 'TAR')<br>&gt; &gt;<br>&gt; &gt; I'm using QGIS to open the layer, with the URL:<br>&gt; &gt; <a href="http://wms-dev/cgi-bin/mapserv?map=/srv/www/htdocs/mapdata/catch.map&amp;spp=TAR" target="_blank">http://wms-dev/cgi-bin/mapserv?map=/srv/www/htdocs/mapdata/catch.map&amp;spp=TAR</a><br>&gt; &gt;<br>&gt; &gt; QGIS appends the request type, etc &amp; it works with<br>&gt; the hard coded "spp"<br>&gt; &gt;<br>&gt; &gt;
 The mapfile also has:<br>&gt; &gt;&nbsp; &nbsp; METADATA<br>&gt; &gt;&nbsp; &nbsp; &nbsp; "wms_title" "species"<br>&gt; &gt;&nbsp; &nbsp;&nbsp;&nbsp;<br>&gt; "wms_srs"&nbsp;&nbsp;&nbsp;"epsg:4326"<br>&gt; &gt;&nbsp; &nbsp; &nbsp; "wfs_title" "species"<br>&gt; &gt;&nbsp; &nbsp; &nbsp; "wfs_version" "1.0.0"<br>&gt; &gt;&nbsp; &nbsp; &nbsp; "wfs_typename" "species"<br>&gt; &gt;&nbsp; &nbsp; &nbsp; "wfs_request_method" "GET"<br>&gt; &gt;&nbsp; &nbsp; &nbsp; "wfs_service" "WFS"<br>&gt; &gt;&nbsp; &nbsp; &nbsp; "spp_validation_pattern"<br>&gt; '^[A-Z0-9][A-Z0-9][A-Z0-9]$'<br>&gt; &gt;&nbsp; &nbsp; END<br>&gt; &gt;<br>&gt; &gt; The version I'm running is MapServer version 5.4.1<br>&gt; &gt; (so no default supported)<br>&gt; &gt;<br>&gt; &gt; The docs say I can use shp2img to test runtime<br>&gt; substitution in a mapfile, but I can't see how to invoke the<br>&gt; substitution with the equivalent of a spp=TAR statement to<br>&gt; test
 this.<br><br>_______________________________________________<br>mapserver-users mailing list<br><a ymailto="mailto:mapserver-users@lists.osgeo.org" href="/mc/compose?to=mapserver-users@lists.osgeo.org">mapserver-users@lists.osgeo.org</a><br><a href="http://lists.osgeo.org/mailman/listinfo/mapserver-users" target="_blank">http://lists.osgeo.org/mailman/listinfo/mapserver-users</a><br></div></blockquote></td></tr></table>