#5047 closed defect (invalid)
ogr2ogr -sql syntax error
Reported by: | sbl | Owned by: | warmerdam |
---|---|---|---|
Priority: | normal | Milestone: | |
Component: | default | Version: | 1.9.2 |
Severity: | normal | Keywords: | SQL |
Cc: |
Description (last modified by )
When converting from shapefile to shapefile (or to PostGIS) ogr2ogr invoked with -sql statement throws error message: "ERROR 1: SQL Expression Parsing Error: syntax error" Even with a simple syntax like: ""SELECT * FROM mylayer". Happend on Ubuntu 12.04 server.
Change History (5)
comment:1 by , 11 years ago
Resolution: | → invalid |
---|---|
Status: | new → closed |
comment:2 by , 11 years ago
Description: | modified (diff) |
---|
comment:3 by , 11 years ago
Description: | modified (diff) |
---|
I see that it is a fundamental and widely used function, and I will try to find out what could have went wrong on my side. Maybe something went wrong when I compiled GDAL, but I tested lots of different sql-statments and got allways a syntax error... The typo in the description would not have led to an error message at all because the system would waited for the end of the command...
comment:4 by , 11 years ago
Another hypothesis is that your "mylayer" is a SQL reserved keyword for example.
For example :
ogrinfo poly.shp -sql "select * from order" INFO: Open of `poly.shp' using driver `ESRI Shapefile' successful. ERROR 1: SQL Expression Parsing Error: syntax error
comment:5 by , 11 years ago
Thanks, now I found out what was wrong:
The layer names started with a number which obviously is invalid in SQL...
ogr2ogr -sql "SELECT * FROM 32_0626arealressurs_linje" test.shp 32_0626arealressurs_linje.shp -progress ERROR 1: SQL Expression Parsing Error: syntax error ogr2ogr test.shp 32_0626arealressurs_linje.shp -progress 0...10...20...30...40...50...60...70...80...90...100 - done. ogr2ogr -sql "SELECT * FROM test" test_2.shp test.shp -progress 0...10...20...30...40...50...60...70...80...90...100 - done.
Thanks again and sorry for the noise...
I'm pretty sure at 99.9% it is just a typo on your side. This is a basic function well tested by the regression tests. And in your description, there's actually a typo : the double double-quote at the beginning of the SQL.