[Gdal-dev] ODBC can't connect using SQL statement

Frank Warmerdam warmerdam at pobox.com
Wed Nov 15 10:19:37 EST 2006

Eduardo Patto Kanegae wrote:
> Hi,
> I'm trying to access a point data table using MapServer through OGR VRT 
> driver but I'm having errors.
> My data table is at SQL Server 2000 and I already created a system dns 
> for this database.
> If I run:
> $ ogrinfo ODBC:myuser/mypassword at MYDSN -sql "SELECT * FROM PointTable 
> WHERE themonth > 10"
> this works fine
> But when I try in MapServer:
> Then I got:
> /* -----
> msDrawMap(): Image handling error. Failed to draw layer named 'ptsodbc'.
> msOGRFileNextShape(): OGR error. SetAttributeFilter() not supported on 
> ExecuteSQL() results.
> msEvalContext: Expression parser error. Failed to parse context
> msyyparse(): Expression parser error. syntax error
> --- */
> I only was able to filter data at this point table using FILTER and 
> FILTERITEM keywords at mapfile, but only using regular expressions . 
> Logical expressions does not show any point.
> Is that something wrong at my connection string or is this a bug to be 
> solved using GDAL CVS ?


In gda/ogr/ogrsf_frmts/odbc/ogrodbcselectlayer.cpp I see:

  * Revision 1.4  2006/05/15 18:14:31  fwarmerdam
  * Use generic mechanism for SetAttributeFilter() (bug 1185)

Unfortunately this was shortly after the GDAL 1.3.2 release.  So yes,
I believe you need to update to GDAL CVS (well a nightly snapshot is fine).

Best regards,
I set the clouds in motion - turn up   | Frank Warmerdam, warmerdam at pobox.com
light and sound - activate the windows | http://pobox.com/~warmerdam
and watch the world go round - Rush    | President OSGeo, http://osgeo.org

More information about the Gdal-dev mailing list