<html><head></head><body style="word-wrap: break-word; -webkit-nbsp-mode: space; -webkit-line-break: after-white-space; color: rgb(0, 0, 0); font-size: 14px; font-family: Calibri, sans-serif;"><div><div>Yeah, the token processing is going wrong there. </div><div><br></div><div>Can you create a mapserver ticket with a layer snippet to create the problem and assign it to me (or let me know which number it is) and I'll work on fixing it.</div><div><br></div><div>Mike</div><div><div><div>----</div><div>Michael Smith</div></div><div>US Army Corps</div><div>Remote Sensing GIS/Center</div><div>michael.smith@usace.army.mil</div><div><br></div></div></div><div><br></div><span id="OLK_SRC_BODY_SECTION"><div style="font-family:Calibri; font-size:11pt; text-align:left; color:black; BORDER-BOTTOM: medium none; BORDER-LEFT: medium none; PADDING-BOTTOM: 0in; PADDING-LEFT: 0in; PADDING-RIGHT: 0in; BORDER-TOP: #b5c4df 1pt solid; BORDER-RIGHT: medium none; PADDING-TOP: 3pt"><span style="font-weight:bold">From: </span> mapserver-dev <<a href="mailto:mapserver-dev-bounces@lists.osgeo.org">mapserver-dev-bounces@lists.osgeo.org</a>> on behalf of Björn Danielsson <<a href="mailto:bjorn.danielsson@falubo.se">bjorn.danielsson@falubo.se</a>><br><span style="font-weight:bold">Date: </span> Friday, January 29, 2016 at 3:22 AM<br><span style="font-weight:bold">To: </span> Michael Smith <<a href="mailto:michael.smith.erdc@gmail.com">michael.smith.erdc@gmail.com</a>><br><span style="font-weight:bold">Cc: </span> "<a href="mailto:mapserver-dev@lists.osgeo.org">mapserver-dev@lists.osgeo.org</a>" <<a href="mailto:mapserver-dev@lists.osgeo.org">mapserver-dev@lists.osgeo.org</a>><br><span style="font-weight:bold">Subject: </span> Re: [mapserver-dev] [EXTERNAL]  Problem with filter in Oracle<br><span style="font-weight:bold">Resent-From: </span> Michael Smith <<a href="mailto:michael.smith@usace.army.mil">michael.smith@usace.army.mil</a>><br></div><div><br></div><blockquote id="MAC_OUTLOOK_ATTRIBUTION_BLOCKQUOTE" style="BORDER-LEFT: #b5c4df 5 solid; PADDING:0 0 0 5; MARGIN:0 0 0 5;"><div><meta http-equiv="Content-Type" content="text/html; charset=utf-8"><div><div style="font-size: 13.3333px; font-family: tahoma; color: rgb(0, 0, 0); 
font-weight: 400; font-style: normal; background: none 0% 0% / auto repeat 
scroll padding-box border-box rgba(0, 0, 0, 0);">
Hi again,</div><div style="font-size: 13.3333px; font-family: tahoma; color: rgb(0, 0, 0); 
font-weight: 400; font-style: normal; background: none 0% 0% / auto repeat 
scroll padding-box border-box rgba(0, 0, 0, 0);">
 </div><div style="font-size: 13.3333px; font-family: tahoma; color: rgb(0, 0, 0); 
font-weight: 400; font-style: normal; background: none 0% 0% / auto repeat 
scroll padding-box border-box rgba(0, 0, 0, 0);">
I have encountered another difference between postgres and oracle where postgres works ok but oracle does not, and may have an angle towards filter.</div><div style="font-size: 13.3333px; font-family: tahoma; color: rgb(0, 0, 0); 
font-weight: 400; font-style: normal; background: none 0% 0% / auto repeat 
scroll padding-box border-box rgba(0, 0, 0, 0);">
 </div><div style="font-size: 13.3333px; font-family: tahoma; color: rgb(0, 0, 0); 
font-weight: 400; font-style: normal; background: none 0% 0% / auto repeat 
scroll padding-box border-box rgba(0, 0, 0, 0);">
As I mentioned earlier I have two identical databases, one in postgres and the other in oracle.</div><div style="font-size: 13.3333px; font-family: tahoma; color: rgb(0, 0, 0); 
font-weight: 400; font-style: normal; background: none 0% 0% / auto repeat 
scroll padding-box border-box rgba(0, 0, 0, 0);">
 </div><div style="font-size: 13.3333px; font-family: tahoma; color: rgb(0, 0, 0); 
font-weight: 400; font-style: normal; background: none 0% 0% / auto repeat 
scroll padding-box border-box rgba(0, 0, 0, 0);">
It concerns the function queryByAttributes. The documentation of queryByAttributes  is a bit confusing and contradicting so I have more or less used trial and error to get it working. I started with postgres</div><div style="font-family: tahoma; color: rgb(0, 0, 0); font-size: 13.3333px; 
font-weight: 400; font-style: normal; background: none 0% 0% / auto repeat 
scroll padding-box border-box rgba(0, 0, 0, 0);"><div>and finally got it working. But what worked in postgres caused error in oracle.</div><div> </div><div>Mapfile:</div><div><div>  LAYER<br>
    NAME           "AVD"<br>
    GROUP          "AVD"<br>
    CONNECTIONTYPE postgis<br>
    CONNECTION     "host=localhost port=5432 dbname=fwt_prod user=c2 password=C2"<br>
    STATUS         ON<br>
    TYPE           POLYGON<br>
    MINSCALEDENOM  1500<br>
    MAXSCALEDENOM  500000<br>
    LABELMAXSCALEDENOM  21000<br>
    POSTLABELCACHE FALSE<br>
    PROCESSING "LABEL_NO_CLIP=ON"<br>
    LABELCACHE ON<br>
    TEMPLATE   "void"<br>
#    DEBUG 5</div><div>    PROJECTION<br>
      "init=epsg:3006"<br>
    END</div><div> </div><div>php-code for postgres:</div><div> </div><div><div>$oLayer= $oMap->getLayerByName("AVD");<br>
if ($bDebug) {<br>
  fwrite($f,"Layername: ".$oLayer->name."\r\n");<br>
}<br>
$data = "kartobj FROM ".$dbowner.".AVD*AVD USING SRID=".$srid." USING UNIQUE avd";<br>
$data = str_replace("*","$",$data);<br>
$ab = $oLayer->set("data", $data);</div><div>$filter = "([orgid]='".$orgid."' and [fv]='".$fv."' and [bev]='".$bev."' and [skifte]='".$skifte."')";<br>
$aa = $oLayer->setFilter($filter);<br>
        <br>
$ac = $oLayer->setConnectionType(MS_POSTGIS);       <br>
$oLayer->set("connection", $conn);</div><div>$res = @$oLayer->queryByAttributes("avd", "'".$avd."'", MS_SINGLE);<br>
if ($bDebug) {<br>
  fwrite($f,"avd-res: ".$res."\r\n");<br>
}<br>
$oLayer->open();</div><div> </div><div>From debug ( at the end of msPostGISLayerWhichShapes query ):</div><div> </div><div>3922))',0) and ("avd"::text = '250' and "orgid" = 'BSD' and "fv" = 'FV1' and "bev" = '1' and "skifte" = '3235')</div><div> </div><div>Notice "avd"::text='250'.</div><div> </div><div>php_code for oracle:</div><div> </div><div><div>$oLayer= $oMap->getLayerByName("AVD");<br>
if ($bDebug) {<br>
  fwrite($f,"Layername: ".$oLayer->name."\r\n");<br>
}<br>
           <br>
$data = "KARTOBJ_SDO FROM ".$dbowner.".AVD*AVD";<br>
$data = str_replace("*","$",$data);<br>
$ab = $oLayer->set("data", $data);</div><div>$filter = "([ORGID]='".$orgid."' AND [FV]='".$fv."' AND [BEV]='".$bev."' AND [SKIFTE]='".$skifte."')";<br>
$aa = $oLayer->setFilter($filter);<br>
        <br>
$ac = $oLayer->setConnectionType(MS_ORACLESPATIAL);<br>
$oLayer->set("connection", $conn);</div><div>$res = $oLayer->queryByAttributes("AVD", "'".$avd."'", MS_SINGLE);<br>
if ($bDebug) {<br>
  fwrite($f,"avd-res: ".$res."\r\n");<br>
}<br>
$oLayer->open();</div></div><div> </div><div><span style="font-family: tahoma; font-size: 13.3333px;">From debug ( same query as above ):</span></div><div> </div><div>wnum, KARTOBJ_SDO FROM c2.AVD$AVD WHERE  AVD =  AVD = '250' AND ORGID = 'BSD' AND FV = 'FV1' AND BEV = '1' AND SKIFTE = '3235'</div><div> </div><div>Notice WHERE AVD = AVD = '250' which of cause gives ora error 933.</div><div> </div><div>Postgres and oracle obviously either treat the in-arguments to queryByAttributes differently or there is a bug somewhere. I would very much like to get the thing going in oracle so if there is anything I can do to test further I will be glad to help.</div><div> </div><div>That goes with the previous filter problems too.</div><div> </div><div>Björn D</div></div></div><blockquote style="PADDING-RIGHT: 0px; PADDING-LEFT: 5px; MARGIN-LEFT: 5px; 
BORDER-LEFT: #000000 2px solid; MARGIN-RIGHT: 0px">
-----Original Message-----<br>
From: Michael Smith <<a href="mailto:michael.smith.erdc@gmail.com">michael.smith.erdc@gmail.com</a>><br>
To: Björn Danielsson <<a href="mailto:bjorn.danielsson@falubo.se">bjorn.danielsson@falubo.se</a>><br>
Cc: <<a href="mailto:mapserver-dev@lists.osgeo.org">mapserver-dev@lists.osgeo.org</a>><br>
Date: Mon, 18 Jan 2016 07:43:31 -0500<br>
Subject: Re: [EXTERNAL] [mapserver-dev] Problem with filter in Oracle<br>
 
<div>No, there is no check on the number of records. In both queries, the spatial filter is passed but in the second one, there is no other filter. </div><div> </div><div>If both queries are returning rows in sqlplus, then I think you need to look at the rendering side. Perhaps you have something that is preventing the image from drawing if ID is set?</div><div> </div><div>You can also increase the DEBUG value to 5 and see the rows produced by each query but if both are producing rows in sqlplus, they should in mapserver. </div><div> </div><div>And the :ordinates bind value does include the sdo_ordinate_array type being passed. </div><div> </div><div>First query:  </div><div> </div><div>SELECT ID, rownum, KARTOBJ_SDO FROM c2.KARTA$TMP2 WHERE  ID = '1eokfraqi19niup7402g3iflp7'  AND SDO_FILTER( KARTOBJ_SDO, MDSYS.SDO_GEOMETRY(2003, :srid, NULL,MDSYS.SDO_ELEM_INFO_ARRAY(1,1003,3),:ordinates),'querytype=window') = 'TRUE'</div><div> </div><div>Second query: </div><div>SELECT rownum, KARTOBJ_SDO FROM c2.KARTA$TMP2 WHERE SDO_FILTER( KARTOBJ_SDO, MDSYS.SDO_GEOMETRY(2003, :srid, NULL,MDSYS.SDO_ELEM_INFO_ARRAY(1,1003,3),:ordinates),'querytype=window') = 'TRUE'</div><div> </div><div>Mike</div><div> </div><div> </div><div> </div><div style="font-family:Calibri; font-size:11pt; text-align:left; 
color:black; BORDER-BOTTOM: medium none; BORDER-LEFT: medium none; 
PADDING-BOTTOM: 0in; PADDING-LEFT: 0in; PADDING-RIGHT: 0in; BORDER-TOP: 
#b5c4df 1pt solid; BORDER-RIGHT: medium none; PADDING-TOP: 3pt"><span id="OLK_SRC_BODY_SECTION"><span style="font-weight:bold">From: </span>Björn Danielsson <<a href="mailto:bjorn.danielsson@falubo.se"> bjorn.danielsson@falubo.se</a>><br><span style="font-weight:bold">Date: </span>Monday, January 18, 2016 at 3:33 AM<br><span style="font-weight:bold">To: </span>Michael Smith <<a href="mailto:michael.smith.erdc@gmail.com">michael.smith.erdc@gmail.com</a> ><br><span style="font-weight:bold">Cc: </span><<a href="mailto:mapserver-dev@lists.osgeo.org">mapserver-dev@lists.osgeo.org</a> ><br><span style="font-weight:bold">Subject: </span>Re: [EXTERNAL] [mapserver-dev] Problem with filter in Oracle</span></div><div> </div><blockquote id="MAC_OUTLOOK_ATTRIBUTION_BLOCKQUOTE" style="BORDER-LEFT: 
#b5c4df 5 solid; PADDING:0 0 0 5; MARGIN:0 0 0 5;"><div><div><div style="font-size: 13.3333px; font-family: tahoma; color: rgb(0, 0, 0); 
font-weight: 400; font-style: normal; background: none 0% 0% / auto repeat 
scroll padding-box border-box rgba(0, 0, 0, 0);"><span id="OLK_SRC_BODY_SECTION">Hi Michael,</span></div><div style="font-size: 13.3333px; font-family: tahoma; color: rgb(0, 0, 0); 
font-weight: 400; font-style: normal; background: none 0% 0% / auto repeat 
scroll padding-box border-box rgba(0, 0, 0, 0);"><span id="OLK_SRC_BODY_SECTION">Sorry, I did not notice that I only replied to your private address.</span></div><div style="font-size: 13.3333px; font-family: tahoma; color: rgb(0, 0, 0); 
font-weight: 400; font-style: normal; background: none 0% 0% / auto repeat 
scroll padding-box border-box rgba(0, 0, 0, 0);"><span id="OLK_SRC_BODY_SECTION"> </span></div><div style="font-size: 13.3333px; font-family: tahoma; color: rgb(0, 0, 0); 
font-weight: 400; font-style: normal; background: none 0% 0% / auto repeat 
scroll padding-box border-box rgba(0, 0, 0, 0);"><span id="OLK_SRC_BODY_SECTION">Anyway, I followed your advice and set DEBUG 3 in layer 'X', and made two runs: one with filter set and one with filter not set. The debug output for both runs is in the included ms_error.txt-file.</span></div><div style="font-size: 13.3333px; font-family: tahoma; color: rgb(0, 0, 0); 
font-weight: 400; font-style: normal; background: none 0% 0% / auto repeat 
scroll padding-box border-box rgba(0, 0, 0, 0);"><span id="OLK_SRC_BODY_SECTION"> </span></div><div style="font-size: 13.3333px; font-family: tahoma; color: rgb(0, 0, 0); 
font-weight: 400; font-style: normal; background: none 0% 0% / auto repeat 
scroll padding-box border-box rgba(0, 0, 0, 0);"><span id="OLK_SRC_BODY_SECTION">The one with filter set produce an empty image. The one with filter not set works fine.</span></div><div style="font-size: 13.3333px; font-family: tahoma; color: rgb(0, 0, 0); 
font-weight: 400; font-style: normal; background: none 0% 0% / auto repeat 
scroll padding-box border-box rgba(0, 0, 0, 0);"><span id="OLK_SRC_BODY_SECTION"> </span></div><div style="font-size: 13.3333px; font-family: tahoma; color: rgb(0, 0, 0); 
font-weight: 400; font-style: normal; background: none 0% 0% / auto repeat 
scroll padding-box border-box rgba(0, 0, 0, 0);"><span id="OLK_SRC_BODY_SECTION">I took the statement from 'Using this Sql to retrieve data', replaced :srid with -1 and :ordinates with SDO_ORDINATE_ARRAY(393339.5,6773950.0,394169.5,6774780.0) and ran the statement in sqlplus.</span></div><div style="font-size: 13.3333px; font-family: tahoma; color: rgb(0, 0, 0); 
font-weight: 400; font-style: normal; background: none 0% 0% / auto repeat 
scroll padding-box border-box rgba(0, 0, 0, 0);"><span id="OLK_SRC_BODY_SECTION">Both examples worked.</span></div><div style="font-size: 13.3333px; font-family: tahoma; color: rgb(0, 0, 0); 
font-weight: 400; font-style: normal; background: none 0% 0% / auto repeat 
scroll padding-box border-box rgba(0, 0, 0, 0);"><span id="OLK_SRC_BODY_SECTION">So I am a bit at loss. The only thing I can see in the debug file is that :ordinates is not declared in 'Bind values' but the rectangle's extents are. But I don't know what goes on behind the scene so that might be correct. It
 feels strange though that this would affect the filter. Or can it be that oracle spatial detects that the table ( when filter not set ) contains only one record and therefore skip the sdo-filtering altogether?</span></div><div style="font-size: 13.3333px; font-family: tahoma; color: rgb(0, 0, 0); 
font-weight: 400; font-style: normal; background: none 0% 0% / auto repeat 
scroll padding-box border-box rgba(0, 0, 0, 0);"><span id="OLK_SRC_BODY_SECTION"> </span></div><div style="font-size: 13.3333px; font-family: tahoma; color: rgb(0, 0, 0); 
font-weight: 400; font-style: normal; background: none 0% 0% / auto repeat 
scroll padding-box border-box rgba(0, 0, 0, 0);"><span id="OLK_SRC_BODY_SECTION">Björn D</span></div><div style="font-family: tahoma; color: rgb(0, 0, 0); font-size: 13.3333px; 
font-weight: 400; font-style: normal; background: none 0% 0% / auto repeat 
scroll padding-box border-box rgba(0, 0, 0, 0);"><span id="OLK_SRC_BODY_SECTION">  </span><blockquote style="PADDING-RIGHT: 0px; PADDING-LEFT: 5px; MARGIN-LEFT: 5px; 
BORDER-LEFT: #000000 2px solid; MARGIN-RIGHT: 0px"><span id="OLK_SRC_BODY_SECTION">-----Original Message-----<br>
From: Michael Smith <<a href="mailto:michael.smith.erdc@gmail.com"> michael.smith.erdc@gmail.com</a>><br>
To: Björn Danielsson <<a href="mailto:bjorn.danielsson@falubo.se"> bjorn.danielsson@falubo.se</a>>, <<a href="mailto:mapserver-users@lists.osgeo.org"> mapserver-users@lists.osgeo.org</a>><br>
Date: Fri, 15 Jan 2016 07:04:55 -0500<br>
Subject: Re: [EXTERNAL] [mapserver-dev] Problem with filter in Oracle<br>
  </span><div><span id="OLK_SRC_BODY_SECTION">Always reply back to the list, others can assist also.</span></div><div><span id="OLK_SRC_BODY_SECTION"> </span></div><div><span id="OLK_SRC_BODY_SECTION">You need to set the DEBUG 3 at the layer level in your mapfile and then the actual queries sent to Oracle will be displayed in the log file (as well as any spatial bind values). Then you can run those queries outside of
 mapserver and verify whether you are getting the rows of data you expect or not.</span></div><div><span id="OLK_SRC_BODY_SECTION"> </span></div><div><span id="OLK_SRC_BODY_SECTION">Mike</span></div><div><span id="OLK_SRC_BODY_SECTION"> </span></div><div><div><div><div><span id="OLK_SRC_BODY_SECTION">----</span></div><div><span id="OLK_SRC_BODY_SECTION">Michael Smith</span></div></div><div><span id="OLK_SRC_BODY_SECTION">US Army Corps</span></div><div><span id="OLK_SRC_BODY_SECTION">Remote Sensing GIS/Center</span></div><div><span id="OLK_SRC_BODY_SECTION"><a href="mailto:michael.smith@usace.army.mil">michael.smith@usace.army.mil</a></span></div><div><span id="OLK_SRC_BODY_SECTION"> </span></div></div></div><div><span id="OLK_SRC_BODY_SECTION"> </span></div><div style="font-family:Calibri; font-size:11pt; text-align:left; 
color:black; BORDER-BOTTOM: medium none; BORDER-LEFT: medium none; 
PADDING-BOTTOM: 0in; PADDING-LEFT: 0in; PADDING-RIGHT: 0in; BORDER-TOP: 
#b5c4df 1pt solid; BORDER-RIGHT: medium none; PADDING-TOP: 3pt"><span id="OLK_SRC_BODY_SECTION"><span id="OLK_SRC_BODY_SECTION"><span style="font-weight:bold">From:
</span>Björn Danielsson <<a href="mailto:bjorn.danielsson@falubo.se"> bjorn.danielsson@falubo.se</a> ><br><span style="font-weight:bold">Date: </span>Friday, January 15, 2016 at 2:40 AM<br><span style="font-weight:bold">To: </span>Michael Smith <<a href="mailto:michael.smith.erdc@gmail.com">michael.smith.erdc@gmail.com</a> ><br><span style="font-weight:bold">Subject: </span>Re: [EXTERNAL] [mapserver-dev] Problem with filter in Oracle</span></span></div><div><span id="OLK_SRC_BODY_SECTION"> </span></div><blockquote id="MAC_OUTLOOK_ATTRIBUTION_BLOCKQUOTE" style="BORDER-LEFT: 
#b5c4df 5 solid; PADDING:0 0 0 5; MARGIN:0 0 0 5;"><div><div><div style="font-size: 13.3333px; font-family: tahoma; color: rgb(0, 0, 0); 
font-weight: 400; font-style: normal;"><span id="OLK_SRC_BODY_SECTION"><span id="OLK_SRC_BODY_SECTION">Hi Michael and thanks for your quick response.</span></span></div><div style="font-size: 13.3333px; font-family: tahoma; color: rgb(0, 0, 0); 
font-weight: 400; font-style: normal;"><span id="OLK_SRC_BODY_SECTION"><span id="OLK_SRC_BODY_SECTION"> </span></span></div><div style="font-size: 13.3333px; font-family: tahoma; color: rgb(0, 0, 0); 
font-weight: 400; font-style: normal;"><span id="OLK_SRC_BODY_SECTION"><span id="OLK_SRC_BODY_SECTION">I did 3 runs with debuglevel 3 and the outcome from the debugger does not say me much.</span></span></div><div style="font-size: 13.3333px; font-family: tahoma; color: rgb(0, 0, 0); 
font-weight: 400; font-style: normal;"><span id="OLK_SRC_BODY_SECTION"><span id="OLK_SRC_BODY_SECTION"> </span></span></div><div style="font-size: 13.3333px; font-family: tahoma; color: rgb(0, 0, 0); 
font-weight: 400; font-style: normal;"><span id="OLK_SRC_BODY_SECTION"><span id="OLK_SRC_BODY_SECTION">  DEBUG              3<br>
  CONFIG             "MS_ERRORFILE" "/ms4w/tmp/ms_error.txt"</span></span> </div><div style="font-family: tahoma; color: rgb(0, 0, 0); font-size: 13.3333px; 
font-weight: 400; font-style: normal;"><div><span id="OLK_SRC_BODY_SECTION"><span id="OLK_SRC_BODY_SECTION"> </span></span></div><div><span id="OLK_SRC_BODY_SECTION"><span id="OLK_SRC_BODY_SECTION">I also activated the 'debugger' in my php scripts that writes a lot, among other things the database calls, to a file.</span></span></div><div><span id="OLK_SRC_BODY_SECTION"><span id="OLK_SRC_BODY_SECTION"> </span></span></div><div><span id="OLK_SRC_BODY_SECTION"><span id="OLK_SRC_BODY_SECTION">The three runs and the resulting debug files are called A,B and C. From mapserver debug 'ms_error_A.txt', and from php debug 'php_debug_A.log'. Look for 'filter = ' in the php debug files.</span></span></div><div><span id="OLK_SRC_BODY_SECTION"><span id="OLK_SRC_BODY_SECTION"> </span></span></div><div><span id="OLK_SRC_BODY_SECTION"><span id="OLK_SRC_BODY_SECTION">A, B and C refer to the examples in my original mail.</span></span></div><div><span id="OLK_SRC_BODY_SECTION"><span id="OLK_SRC_BODY_SECTION"> </span></span></div><div><span id="OLK_SRC_BODY_SECTION"><span id="OLK_SRC_BODY_SECTION">Run A shows the example:</span></span></div><div><span id="OLK_SRC_BODY_SECTION"><span id="OLK_SRC_BODY_SECTION">     $filter = "([ID]='".$sessid."')";</span></span></div><div><span id="OLK_SRC_BODY_SECTION"><span id="OLK_SRC_BODY_SECTION">with the layers 'AVD' and 'X' where 'AVD' works fine and 'X' does not.</span></span></div><div><span id="OLK_SRC_BODY_SECTION"><span id="OLK_SRC_BODY_SECTION"> </span></span></div><div><span id="OLK_SRC_BODY_SECTION"><span id="OLK_SRC_BODY_SECTION">Run B and C is from the same php script with different contents in filter.</span></span></div><div><span id="OLK_SRC_BODY_SECTION"><span id="OLK_SRC_BODY_SECTION">Look for layers 'AVD' and 'AVD-L'. Actually the same table and column. Layer 'AVD' shows polygons and layer 'AVD-L' the polygons' outlines.</span></span></div><div><span id="OLK_SRC_BODY_SECTION"><span id="OLK_SRC_BODY_SECTION">Run C works and run B does not.</span></span></div><div><span id="OLK_SRC_BODY_SECTION"><span id="OLK_SRC_BODY_SECTION">The column SKIFTE in run B is surrounded by parenthesis because it may be like (SKIFTE='A' OR SKIFTE='C' OR ...) because mapserver obviously no longer supports the 'in'-statement. I have tried
 without parenthesis but that did not change anything.</span></span></div><div><span id="OLK_SRC_BODY_SECTION"><span id="OLK_SRC_BODY_SECTION"> </span></span></div><div><span id="OLK_SRC_BODY_SECTION"><span id="OLK_SRC_BODY_SECTION">I can't see any pattern in this.</span></span></div><div><span id="OLK_SRC_BODY_SECTION"><span id="OLK_SRC_BODY_SECTION"> </span></span></div><div><span id="OLK_SRC_BODY_SECTION"><span id="OLK_SRC_BODY_SECTION">Björn Danielsson</span></span></div><blockquote style="PADDING-RIGHT: 0px; PADDING-LEFT: 5px; MARGIN-LEFT: 5px; 
BORDER-LEFT: #000000 2px solid; MARGIN-RIGHT: 0px"><span id="OLK_SRC_BODY_SECTION"><span id="OLK_SRC_BODY_SECTION">-----Original Message-----<br>
From: Michael Smith <<a href="mailto:michael.smith.erdc@gmail.com"> michael.smith.erdc@gmail.com</a>><br>
To: Björn Danielsson <<a href="mailto:bjorn.danielsson@falubo.se"> bjorn.danielsson@falubo.se</a>>, "<a href="mailto:mapserver-dev@lists.osgeo.org">mapserver-dev@lists.osgeo.org</a> " <<a href="mailto:mapserver-dev@lists.osgeo.org"> mapserver-dev@lists.osgeo.org</a>><br>
Date: Thu, 14 Jan 2016 09:35:31 -0500<br>
Subject: Re: [EXTERNAL] [mapserver-dev] Problem with filter in Oracle<br>
  </span></span><div><span id="OLK_SRC_BODY_SECTION"><span id="OLK_SRC_BODY_SECTION"><span style="font-family: Calibri; 
font-size: 15px;">Björn,</span></span></span></div><div><span id="OLK_SRC_BODY_SECTION"><span id="OLK_SRC_BODY_SECTION"> </span></span></div><div><span id="OLK_SRC_BODY_SECTION"><span id="OLK_SRC_BODY_SECTION"><span style="font-family: Calibri; 
font-size: 15px;">Can you turn on DEBUG level 3 and show what queries are being generated? </span></span></span></div><div><span id="OLK_SRC_BODY_SECTION"><span id="OLK_SRC_BODY_SECTION"> </span></span></div><div><span id="OLK_SRC_BODY_SECTION"><span id="OLK_SRC_BODY_SECTION"><span style="font-family: Calibri; 
font-size: 15px;">That will help isolate whats going on with the queries to the backend.</span></span></span></div><div><span id="OLK_SRC_BODY_SECTION"><span id="OLK_SRC_BODY_SECTION"> </span></span></div><div><span id="OLK_SRC_BODY_SECTION"><span id="OLK_SRC_BODY_SECTION"><span style="font-family: Calibri; 
font-size: 15px;">Mike</span></span></span></div><div><span id="OLK_SRC_BODY_SECTION"><span id="OLK_SRC_BODY_SECTION"> </span></span></div><div><div><div><div><span id="OLK_SRC_BODY_SECTION"><span id="OLK_SRC_BODY_SECTION">-- </span></span></div><div><span id="OLK_SRC_BODY_SECTION"><span id="OLK_SRC_BODY_SECTION">Michael Smith</span></span></div></div><div><span id="OLK_SRC_BODY_SECTION"><span id="OLK_SRC_BODY_SECTION">Remote Sensing/GIS Center</span></span></div><div><span id="OLK_SRC_BODY_SECTION"><span id="OLK_SRC_BODY_SECTION">US Army Corps of Engineers</span></span></div></div></div><div style="font-family:Calibri; font-size:11pt; text-align:left; 
color:black; BORDER-BOTTOM: medium none; BORDER-LEFT: medium none; 
PADDING-BOTTOM: 0in; PADDING-LEFT: 0in; PADDING-RIGHT: 0in; BORDER-TOP: 
#b5c4df 1pt solid; BORDER-RIGHT: medium none; PADDING-TOP: 3pt"><span id="OLK_SRC_BODY_SECTION"><span id="OLK_SRC_BODY_SECTION"><span id="OLK_SRC_BODY_SECTION"><span style="font-weight:bold">From:
</span>mapserver-dev <<a href="mailto:mapserver-dev-bounces@lists.osgeo.org"> mapserver-dev-bounces@lists.osgeo.org</a>> on behalf of Björn Danielsson <<a href="mailto:bjorn.danielsson@falubo.se"> bjorn.danielsson@falubo.se</a>><br><span style="font-weight:bold">Date: </span>Thursday, January 14, 2016 at 4:30 AM<br><span style="font-weight:bold">To: </span>"<a href="mailto:mapserver-dev@lists.osgeo.org">mapserver-dev@lists.osgeo.org</a> " <<a href="mailto:mapserver-dev@lists.osgeo.org"> mapserver-dev@lists.osgeo.org</a>><br><span style="font-weight:bold">Subject: </span>[EXTERNAL] [mapserver-dev] Problem with filter in Oracle<br><span style="font-weight:bold">Resent-From: </span>Michael Smith <<a href="mailto:michael.smith@usace.army.mil">michael.smith@usace.army.mil</a> ></span></span></span></div><div><span id="OLK_SRC_BODY_SECTION"><span id="OLK_SRC_BODY_SECTION"> </span></span></div><blockquote id="MAC_OUTLOOK_ATTRIBUTION_BLOCKQUOTE" style="BORDER-LEFT: 
#b5c4df 5 solid; PADDING:0 0 0 5; MARGIN:0 0 0 5;"><div><div><div style="font-size: 13.3333px; font-family: tahoma; color: rgb(0, 0, 0); 
font-weight: 400; font-style: normal; background: none 0% 0% / auto repeat 
scroll padding-box border-box rgba(0, 0, 0, 0);"><span id="OLK_SRC_BODY_SECTION"><span id="OLK_SRC_BODY_SECTION"><span id="OLK_SRC_BODY_SECTION">Hi,</span></span></span></div><div style="font-size: 13.3333px; font-family: tahoma; color: rgb(0, 0, 0); 
font-weight: 400; font-style: normal; background: none 0% 0% / auto repeat 
scroll padding-box border-box rgba(0, 0, 0, 0);"><span id="OLK_SRC_BODY_SECTION"><span id="OLK_SRC_BODY_SECTION"><span id="OLK_SRC_BODY_SECTION"> </span></span></span></div><div style="font-size: 13.3333px; font-family: tahoma; color: rgb(0, 0, 0); 
font-weight: 400; font-style: normal; background: none 0% 0% / auto repeat 
scroll padding-box border-box rgba(0, 0, 0, 0);"><span id="OLK_SRC_BODY_SECTION"><span id="OLK_SRC_BODY_SECTION"><span id="OLK_SRC_BODY_SECTION">I have been using ms4w for quite some time and have discovered problems with Oracle when using php_mapscript. I posted this problem at ms4w's support and was adviced
 to turn to you.</span></span> </span></div><div style="font-size: 13.3333px; font-family: tahoma; color: rgb(0, 0, 0); 
font-weight: 400; font-style: normal; background: none 0% 0% / auto repeat 
scroll padding-box border-box rgba(0, 0, 0, 0);"><span id="OLK_SRC_BODY_SECTION"><span id="OLK_SRC_BODY_SECTION"><span id="OLK_SRC_BODY_SECTION"> </span></span></span></div><div style="font-size: 13.3333px; font-family: tahoma; color: rgb(0, 0, 0); 
font-weight: 400; font-style: normal; background: none 0% 0% / auto repeat 
scroll padding-box border-box rgba(0, 0, 0, 0);"><span id="OLK_SRC_BODY_SECTION"><span id="OLK_SRC_BODY_SECTION"><span id="OLK_SRC_BODY_SECTION">I am supporting a gis-system on the web that is heavily database dependent, and can run on either postgres or oracle according to the costumer's request. So there
 are two sets of php-scripts that are identical apart from the database calls.</span></span></span></div><div style="font-size: 13.3333px; font-family: tahoma; color: rgb(0, 0, 0); 
font-weight: 400; font-style: normal; background: none 0% 0% / auto repeat 
scroll padding-box border-box rgba(0, 0, 0, 0);"><span id="OLK_SRC_BODY_SECTION"><span id="OLK_SRC_BODY_SECTION"><span id="OLK_SRC_BODY_SECTION"> </span></span></span></div><div style="font-size: 13.3333px; font-family: tahoma; color: rgb(0, 0, 0); 
font-weight: 400; font-style: normal; background: none 0% 0% / auto repeat 
scroll padding-box border-box rgba(0, 0, 0, 0);"><span id="OLK_SRC_BODY_SECTION"><span id="OLK_SRC_BODY_SECTION"><span id="OLK_SRC_BODY_SECTION">Thera are no problems with postgres.</span></span></span></div><div style="font-size: 13.3333px; font-family: tahoma; color: rgb(0, 0, 0); 
font-weight: 400; font-style: normal; background: none 0% 0% / auto repeat 
scroll padding-box border-box rgba(0, 0, 0, 0);"><span id="OLK_SRC_BODY_SECTION"><span id="OLK_SRC_BODY_SECTION"><span id="OLK_SRC_BODY_SECTION"> </span></span></span></div><div style="font-size: 13.3333px; font-family: tahoma; color: rgb(0, 0, 0); 
font-weight: 400; font-style: normal; background: none 0% 0% / auto repeat 
scroll padding-box border-box rgba(0, 0, 0, 0);"><span id="OLK_SRC_BODY_SECTION"><span id="OLK_SRC_BODY_SECTION"><span id="OLK_SRC_BODY_SECTION">With Oracle there is a funny problem with filter.</span></span></span></div><div style="font-size: 13.3333px; font-family: tahoma; color: rgb(0, 0, 0); 
font-weight: 400; font-style: normal; background: none 0% 0% / auto repeat 
scroll padding-box border-box rgba(0, 0, 0, 0);"><span id="OLK_SRC_BODY_SECTION"><span id="OLK_SRC_BODY_SECTION"><span id="OLK_SRC_BODY_SECTION">Look at this:</span></span></span></div><div style="font-size: 13.3333px; font-family: tahoma; color: rgb(0, 0, 0); 
font-weight: 400; font-style: normal; background: none 0% 0% / auto repeat 
scroll padding-box border-box rgba(0, 0, 0, 0);"><span id="OLK_SRC_BODY_SECTION"><span id="OLK_SRC_BODY_SECTION"><span id="OLK_SRC_BODY_SECTION"> 
</span></span></span><div><span id="OLK_SRC_BODY_SECTION"><span id="OLK_SRC_BODY_SECTION"><span id="OLK_SRC_BODY_SECTION">foreach($aLayersIdx as $layerIndex) {<br>
  $oLayerK = $oMapK->getLayer($layerIndex);<br>
if ($bDebug) {<br>
  fwrite($f,"layer: ".$oLayerK->name."\r\n");<br>
}</span></span></span></div><div><span id="OLK_SRC_BODY_SECTION"><span id="OLK_SRC_BODY_SECTION"><span id="OLK_SRC_BODY_SECTION">  if ($oLayerK->name == "AVD" && $avd == "") {<br>
    $oLayerK->set("status",MS_OFF);<br>
    continue;<br>
  }</span></span></span></div><div><span id="OLK_SRC_BODY_SECTION"><span id="OLK_SRC_BODY_SECTION"><span id="OLK_SRC_BODY_SECTION">  $filter = "";<br>
  switch ($oLayerK->name) {<br>
    case "AVD" :<br>
      $filter = "([ORGID]='".$orgid."' AND [FV]='".$fv."' AND [BEV]='".$bev."' AND [SKIFTE]='".$skifte."' AND [AVD]='".$avd."')";<br>
      $data = "KARTOBJ_SDO FROM ".$dbowner.".AVD*AVD";<br>
      break;<br>
      <br>
    case "X" :<br>
      $filter = "([ID]='".$sessid."')";<br>
      $data = "KARTOBJ_SDO FROM ".$dbowner.".KARTA*TMP2";<br>
      break;<br>
  }<br>
  <br>
  $data = str_replace("*","$",$data);<br>
 <br>
  $oLayerK->set("data", $data);<br>
  $oLayerK->setFilter($filter);<br>
  $oLayerK->setConnectionType(MS_ORACLESPATIAL);<br>
  $oLayerK->set("connection", $conn);<br>
  $oLayerK->set("status", MS_ON);<br>
  if ($bDebug) {<br>
    fwrite($f,"connection: ".$conn."\r\n");<br>
    fwrite($f,"filter: ".$filter."\r\n");<br>
    fwrite($f,"data: ".$data."\r\n");<br>
  }  <br>
}</span></span></span></div><div><span id="OLK_SRC_BODY_SECTION"><span id="OLK_SRC_BODY_SECTION"><span id="OLK_SRC_BODY_SECTION"> </span></span></span></div><div><span id="OLK_SRC_BODY_SECTION"><span id="OLK_SRC_BODY_SECTION"><span id="OLK_SRC_BODY_SECTION">A mapfile with two layers, 'AVD' and 'X'.</span></span></span></div><div><span id="OLK_SRC_BODY_SECTION"><span id="OLK_SRC_BODY_SECTION"><span id="OLK_SRC_BODY_SECTION">Problem is that filter for layer 'X' does not work. Or, rather, it works but no record is returned. The mapserver debugger reports no error.</span></span></span></div><div><span id="OLK_SRC_BODY_SECTION"><span id="OLK_SRC_BODY_SECTION"><span id="OLK_SRC_BODY_SECTION">The filter for layer 'AVD' works fine.</span></span></span></div><div><span id="OLK_SRC_BODY_SECTION"><span id="OLK_SRC_BODY_SECTION"><span id="OLK_SRC_BODY_SECTION"> </span></span></span></div><div><span id="OLK_SRC_BODY_SECTION"><span id="OLK_SRC_BODY_SECTION"><span id="OLK_SRC_BODY_SECTION">When the line $filter = "[ID]='".$sessid."')" is commented and the table KARTA$TMP2 contains only one record it works and a map layer is produced. So it seems
 that when filter is introduced in the select something goes wrong.</span></span></span></div><div><span id="OLK_SRC_BODY_SECTION"><span id="OLK_SRC_BODY_SECTION"><span id="OLK_SRC_BODY_SECTION"> </span></span></span></div><div><span id="OLK_SRC_BODY_SECTION"><span id="OLK_SRC_BODY_SECTION"><span id="OLK_SRC_BODY_SECTION">I thought that ID might be a reserved word but after some testing I found that filter fails in calls to other tables as well.</span></span></span></div><div><span id="OLK_SRC_BODY_SECTION"><span id="OLK_SRC_BODY_SECTION"><span id="OLK_SRC_BODY_SECTION">For example:</span></span></span></div><div><span id="OLK_SRC_BODY_SECTION"><span id="OLK_SRC_BODY_SECTION"><span id="OLK_SRC_BODY_SECTION">This works</span></span></span></div><div><span id="OLK_SRC_BODY_SECTION"><span id="OLK_SRC_BODY_SECTION"><span id="OLK_SRC_BODY_SECTION">     $filter = "([ORGID]='".$orgid."' AND [FV]='".$fv."' AND [BEV]='".$bev."')";</span></span></span></div><div><span id="OLK_SRC_BODY_SECTION"><span id="OLK_SRC_BODY_SECTION"><span id="OLK_SRC_BODY_SECTION">But this does not work</span></span></span></div><div><span id="OLK_SRC_BODY_SECTION"><span id="OLK_SRC_BODY_SECTION"><span id="OLK_SRC_BODY_SECTION"><span style="font-family: tahoma; 
font-size: 13.3333px;">     $filter = "([ORGID]='".$orgid."' AND [FV]='".$fv."' AND [BEV]='".$bev."' AND [SKIFTE]='".$skifte."')";</span></span></span></span></div><div><span id="OLK_SRC_BODY_SECTION"><span id="OLK_SRC_BODY_SECTION"><span id="OLK_SRC_BODY_SECTION"> </span></span></span></div><div><span id="OLK_SRC_BODY_SECTION"><span id="OLK_SRC_BODY_SECTION"><span id="OLK_SRC_BODY_SECTION">The problem is consistent in that way that where the problem occurs it always occurs, and where it not occurs it never occurs. It is not intermittent.</span></span></span></div><div><span id="OLK_SRC_BODY_SECTION"><span id="OLK_SRC_BODY_SECTION"><span id="OLK_SRC_BODY_SECTION"> </span></span></span></div><div><span id="OLK_SRC_BODY_SECTION"><span id="OLK_SRC_BODY_SECTION"><span id="OLK_SRC_BODY_SECTION">The php script ( where the snippet came from above ) was developed under ms4w version 2.2.7 and at that time no problems occured. I have also used version 3.0.6
 and 3.1.1 and both versions have problems. So somewhere between 2.2.7 and 3.0.6 something happened.</span></span></span></div><div><span id="OLK_SRC_BODY_SECTION"><span id="OLK_SRC_BODY_SECTION"><span id="OLK_SRC_BODY_SECTION"> </span></span></span></div><div><span id="OLK_SRC_BODY_SECTION"><span id="OLK_SRC_BODY_SECTION"><span id="OLK_SRC_BODY_SECTION">I am at loss here.</span></span></span></div><div><span id="OLK_SRC_BODY_SECTION"><span id="OLK_SRC_BODY_SECTION"><span id="OLK_SRC_BODY_SECTION"> </span></span></span></div><div><span id="OLK_SRC_BODY_SECTION"><span id="OLK_SRC_BODY_SECTION"><span id="OLK_SRC_BODY_SECTION">Björn Danielsson</span></span></span></div></div></div></div></blockquote></blockquote></div></div></div></blockquote></blockquote></div></div></div></blockquote></blockquote></div></div></div></blockquote></span></body></html>