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

Rahkonen Jukka Jukka.Rahkonen at mmmtike.fi
Fri Oct 5 09:34:12 PDT 2012


Even Rouault wrote:


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

>> > 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""

Yes, that's a good theory but it is not easy to use it on Windows. Does 
anybody in the world know how should this one be escaped? I have 
already tried to use ^" as inner double quotes but without success,
as well as having two ^^ and three ^^^.

gdal_dev>ogrinfo WFS:http://188.64.1.61/cgi-bin/tinyows 
-sql "select "nom.dept" from "tows:dot.test""
INFO: Open of `WFS:http://188.64.1.61/cgi-bin/tinyows'
      using driver `WFS' successful.
ERROR 1: SQL Expression Parsing Error: syntax error

> 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