layerObj.queryByAttributes changed with Oracle

Fernando Simon fsimon at UNIVALI.BR
Thu Nov 29 07:57:40 PST 2007


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 



More information about the MapServer-users mailing list