<HTML><HEAD>
<META http-equiv=Content-Type content="text/html; charset=iso-8859-15">
<META content="MSHTML 6.00.2900.3243" name=GENERATOR></HEAD>
<BODY>
<DIV>Use double %%</DIV>
<DIV>&nbsp;</DIV>
<DIV>"like '%%spp%%'" and pass &amp;spp=TAR</DIV>
<DIV>&nbsp;</DIV>
<DIV>Regards,</DIV>
<DIV>&nbsp;</DIV>
<DIV>Robert<BR><BR>&gt;&gt;&gt; Joshua Hevenor &lt;jhevenor@rogers.com&gt; 15/03/2010 1:03 p.m. &gt;&gt;&gt;<BR></DIV>
<TABLE cellSpacing=0 cellPadding=0 border=0>
<TBODY>
<TR>
<TD vAlign=top>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 defanghtml_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 href="/mc/compose?to=lists@remoteinformation.com.au" defanghtml_ymailto="mailto:lists@remoteinformation.com.au">lists@remoteinformation.com.au</A>&gt; wrote:<BR><BR>&gt; From: Ben Madin &lt;<A href="/mc/compose?to=lists@remoteinformation.com.au" defanghtml_ymailto="mailto:lists@remoteinformation.com.au">lists@remoteinformation.com.au</A>&gt;<BR>&gt; Subject: Re: [mapserver-users] runtime substitution not working<BR>&gt; To: <A href="/mc/compose?to=mapserver-users@lists.osgeo.org" defanghtml_ymailto="mailto:mapserver-users@lists.osgeo.org">mapserver-users@lists.osgeo.org</A><BR>&gt; Cc: <A href="/mc/compose?to=pcreso@pcreso.com" defanghtml_ymailto="mailto: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 href="/mc/compose?to=mapserver-users-request@lists.osgeo.org" defanghtml_ymailto="mailto: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 href="/mc/compose?to=mapserver-users@lists.osgeo.org" defanghtml_ymailto="mailto: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></TBODY></TABLE><BR><BR><FONT style="BACKGROUND-COLOR: #ffffff">
<P align=center><FONT style="BACKGROUND-COLOR: #ffffff">Click <A href="https://www.mailcontrol.com/sr/wQw0zmjPoHdJTZGyOCrrhg==">here</A> to report this email as spam.</FONT></P></FONT><br><br><table bgcolor=white style="color:black"><tr><td><br>------------------------------------------------------------------<br>
The&nbsp;contents&nbsp;of&nbsp;this&nbsp;email&nbsp;are&nbsp;confidential&nbsp;to&nbsp;AsureQuality.&nbsp;If&nbsp;you&nbsp;have&nbsp;received&nbsp;this&nbsp;communication&nbsp;in&nbsp;error&nbsp;please&nbsp;notify&nbsp;the&nbsp;sender&nbsp;immediately&nbsp;and&nbsp;delete&nbsp;the&nbsp;message&nbsp;and&nbsp;any&nbsp;attachments.&nbsp;The&nbsp;opinions&nbsp;expressed&nbsp;in&nbsp;this&nbsp;email&nbsp;are&nbsp;not&nbsp;necessarily&nbsp;those&nbsp;of&nbsp;AsureQuality.&nbsp;This&nbsp;message&nbsp;has&nbsp;been&nbsp;scanned&nbsp;for&nbsp;known&nbsp;viruses&nbsp;before&nbsp;delivery.&nbsp;AsureQuality&nbsp;supports&nbsp;the&nbsp;Unsolicited&nbsp;Electronic&nbsp;Messages&nbsp;Act&nbsp;2007.&nbsp;If&nbsp;you&nbsp;do&nbsp;not&nbsp;wish&nbsp;to&nbsp;receive&nbsp;similar&nbsp;communications&nbsp;in&nbsp;future,&nbsp;please&nbsp;notify&nbsp;the&nbsp;sender&nbsp;of&nbsp;this&nbsp;message.<br>
------------------------------------------------------------------</td></tr></table><br><br>
<P align=center><FONT style="BACKGROUND-COLOR: #ffffff">This message has been scanned for malware by SurfControl plc.  </FONT><A href="http://www.surfcontrol.com/"><FONT style="BACKGROUND-COLOR: #ffffff" color=#000000>www.surfcontrol.com</FONT></A></P>
</body></HTML>