layerObj.queryByAttributes changed with Oracle

Benedikt Rothe umn-ms at HYDROTEC.DE
Thu Nov 29 08:39:40 PST 2007


Hi Fernando

Thanks for your quick response!

Since in many cases the where-part is more complex the easiest  solution 
for me
is to omit the second parameter:
  alayerObj.queryByAttributes(aMapObj, null, 
"ID=4711",mapscript./MS_SINGLE/);

Mmmh. It looks like this parameter was useless all the time anyway!

Thank you very much!
Benedikt

PS: The documentation in 
http://mapserver.gis.umn.edu/docs/reference/mapfile/referencemanual-all-pages
states, that FILTERITEM is only used in conjunction with OGR/Shapefile.


Fernando Simon <fsimon at univali.br> schrieb am 29.11.2007 16:57:40:

> Hi Benedikt,
>     This is a Oracle Spatial driver change for 5.0. And the source of
> this issue was relate with some Filter/FilterItem problems for Oracle
> Spatial in early versions (4.x).
>     The osFilterItem function in the source code is relate with FILTER
> and FILTERITEM definitions for Mapfile (you can see here:
> 
http://mapserver.gis.umn.edu/docs/reference/mapfile/referencemanual-all-pages)
> and Mapscript. In the PHPMapscript, the info for queryByAttribute relate
> that the parameters that you pass will overwrite what you define for
> FILTER/FILTERITEM in Mapfile. In the same doc for queryByAttribute:
> "qitem is the item (attribute) on which the query is performed, and
> qstring is the expression to match."
>      In the source code for 5.0 version this is a new (maybe better)
> interpretation for the docs. I believe that this new way is better when
> compared with the docs.
>      Best regards.
> 
> Fernando Simon
> 
> 
> Benedikt Rothe wrote:
> >
> > Hello List
> >
> > I'm using Mapserer with Oracle/Java-Mapscript and migrating my app
> > from Mapserver 4.x to Mapserer 5.x
> > and have a problem with layerObj.queryByAttributes.
> >
> > I used to query features with code like this:
> >   alayerObj.queryByAttributes(aMapObj, "ID", "ID=4711",
> > mapscript./MS_SINGLE/);
> > In Mapserver 5 this code  results in an Mapserver-Error-Message
> > stating, that the "SQL command is not properly ended".
> >
> > The Mapserver-generated SQL-Command includes a Where-Clause of the
> > form "ID = ID = 4711".
> >
> > I had a look in maporaclespatial.c function "osFilteritem".
> > Follwing code seems to produce this Where-Clause:
> >  if (layer->filteritem != NULL)
> >  {
> >    sprintf (query_str + strlen(query_str), " %s = ", 
layer->filteritem);
> >    //snprintf (query_str + strlen(query_str), " %s = ",
> > layer->filteritem);
> >  }
> >
> > Changing my Java-Code to
> >   alayerObj.queryByAttributes(aMapObj, "ID", "4711",
> > mapscript./MS_SINGLE/);
> > solves the problem.
> >
> > Questions:
> > * Is this a bug in Mapserver or a new feature? 
> > * Is this really a change in Mapserver 5.0?
> > * Shall I rather change my Java-Code or shall I patch Mapserver/
> > maporaclespatial.c/osFilteritem?
> >    Would the changed Java-Code work with the Oracle-driver only?
> >
> > Greetings from Aachen/Germany
> > Benedikt Rothe
> >
> > *Attachement "Error-Message": *(Added Newlines)
> > msOracleSpatialLayerWhichShapes(): OracleSpatial error. Error:
> > ORA-00933: SQL command not properly ended
> >  . Query statement:
> > SELECT
> >   ID, ID, SHAPE
> > FROM
> >   (select ID,SHAPE
> >    FROM MYTABLE)
> >    WHERE  *ID =  ID = 4711*  AND
> >    SDO_FILTER(
> >      SHAPE, MDSYS.SDO_GEOMETRY(2003, 82015,
> >      NULL,MDSYS.SDO_ELEM_INFO_ARRAY(1,1003,3),
> >      MDSYS.SDO_ORDINATE_ARRAY(2501576.69,5621567,2503419.31,5622567)
> > ),'querytype=window') = 'TRUE' .
> > Check your data statement.
> >
> > *Attachement "Part of mapfile":*
> >   # Projekte
> >   LAYER
> >     NAME "PROJEKT"
> >     TYPE POINT
> >     STATUS DEFAULT
> >     #DEBUG ON
> >     TEMPLATE "dummy.html"
> >     CONNECTION "XXX/YYY at ZZZ"
> >     CONNECTIONTYPE oraclespatial
> >     DATA "SHAPE FROM (select ID,SHAPE FROM MYTABLE) using unique ID
> > srid 82015"
> >     CLASS
> >       NAME ""
> >       STYLE
> >         COLOR 0 100 100
> >         OUTLINECOLOR 0 0 0
> >         SIZE 12
> >         SYMBOL 'star'
> >       END
> >     END
> >   END 
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://lists.osgeo.org/pipermail/mapserver-users/attachments/20071129/7c960e12/attachment.htm>


More information about the MapServer-users mailing list