[gdal-dev] OGR SQL: Excecuting select where column name contains "."

Even Rouault even.rouault at mines-paris.org
Fri Oct 5 09:14:36 PDT 2012


Selon Jukka Rahkonen <jukka.rahkonen at mmmtike.fi>:

> Jukka Rahkonen <jukka.rahkonen <at> mmmtike.fi> writes:
>
> > This should definitely work too, but it does not
> > >ogrinfo WFS:http://188.64.1.61/cgi-bin/tinyows -sql "select code_reg from
> tows:
> > france"
> > INFO: Open of `WFS:http://188.64.1.61/cgi-bin/tinyows'
> >       using driver `WFS' successful.
> > ERROR 1: SQL Expression Parsing Error: syntax error
>
>
> Sorry for the undue judgement. This is the correct way to do it on Windows
>
> >ogrinfo WFS:http://188.64.1.61/cgi-bin/tinyows -sql "select 'nom.dept' from
> 'tows:dot.test'"
>
> It is just always as hard for me to remember the right syntax.

OGR SQL follows SQL on this : column and table/layer names are identifiers. So
they must start with a letter or underscore, and subsequent characters must be
letters, underscores or digits. If the identifier is more complex than that, it
must be quoted. To follow SQL, it is recommended to you double-quote characters,
which might require SHELL escaping since they are already in a double-quoted
string, like :

ogrinfo poly.shp -sql "select "eas_id" from "poly""

OGR currently also accepts quoting of column/table names with single-quote
character (which is normally reserved for string literals), but this can lead to
some ambiguity. If you use 'foo', OGR will currently choose the column name foo
if it exists, instead of the string literal 'foo' as standard SQL would mandate.


>
> -Jukka-
>
> _______________________________________________
> gdal-dev mailing list
> gdal-dev at lists.osgeo.org
> http://lists.osgeo.org/mailman/listinfo/gdal-dev
>














More information about the gdal-dev mailing list