Le jeudi 29 novembre 2012 16:28:33, Joe Larson a écrit :
> I have tried these three methods to add a filename column while scripting a
> folder of shapefiles, with a Bash script - which results in `Warning 6:
> Normalized/laundered field name` & `ERROR 1: SQL Expression Parsing Error:
> syntax error` messages and NULL values in the created column :
> 
> #1
> 
> for f in *.shp;
> 
> do
> 
> name=${f%.shp}
> 
> ogrinfo $f -sql "ALTER TABLE $name ADD COLUMN filename character(10)"
> ogrinfo $f -sql "UPDATE TABLE $name filename = '$f'"

--> UPDATE syntax is not supported by OGR SQL dialect. See 
http://gdal.org/ogr/ogr_sql.html

If you use the development version of GDAL (GDAL 1.10dev), you could however 
use the SQLite dialect to do UPDATEs : http://gdal.org/ogr/ogr_sql_sqlite.html

Actually your SQL is incorrect. The correct syntax would be :

ogrinfo $f -dialect SQLite -sql "UPDATE $name SET filename = '$f'"
_______________________________________________
gdal-dev mailing list
[email protected]
http://lists.osgeo.org/mailman/listinfo/gdal-dev

Reply via email to