I want to create a new attribute which is the first 8 characters of another, using ogr2ogr. To my surprise, this didn't work:
ogr2ogr -f "ESRI Shapefile" a.shp b.shp -sql "select FID,left(FLOORKEY,8) AS BLDGKEY,*"
ERROR 1: SQL Expression Parsing Error: syntax error, unexpected LEFT. Occured around :
select FID,left(FLOORKEY,8) AS BLDGKEY,*
^
Choosing the sqlite dialect didn't help either:
ogr2ogr -f "ESRI Shapefile" a.shp b.shp -dialect SQLITE -sql "select FID,left(FLOORKEY,8) AS BLDGKEY,*"
ERROR 1: In ExecuteSQL(): sqlite3_prepare(select FID,left(FLOORKEY,8) AS BLDGKEY,*):
near "(": syntax error
What am I missing? It's GDAL 1.11.0, released 2014/04/16.