Próbuję utworzyć nowe pole w mojej tabeli atrybutów i wstawić wartości z innego pola po konwersji z znaku na liczbę całkowitą, ale nie mogę uzyskać właściwej składni. Uruchamiam to jako skrypt powłoki w MSYS.
cd D:/GIS_DataBase/CorineLC/shps_app_and_extr/
myfile=extr_and_app.shp
name=${myfile%.shp}
ogrinfo $myfile -sql "ALTER TABLE $name ADD COLUMN code_num int(3)"
ogrinfo $myfile -sql "UPDATE TABLE $name SET code_num = CONVERT(code_06 As int(3))"
Komunikat o błędzie (MSYS):
Kay@KAY-PC /c/users/kay/desktop/bash
$ sh calc_field_shp.sh
Warning 6: Unsupported column type 'int'. Defaulting to VARCHAR
INFO: Open of `extr_and_app.shp'
using driver `ESRI Shapefile' successful.
ERROR 1: SQL Expression Parsing Error: syntax error
INFO: Open of `extr_and_app.shp'
using driver `ESRI Shapefile' successful.
Edycja - Kolejna wersja SQLite:
cd D:/GIS_DataBase/CorineLC/shps_app_and_extr/
myfile=extr_and_app.dbf
name=${myfile%.dbf}
ogrinfo $myfile -sql "ALTER TABLE $name DROP COLUMN code_num"
ogrinfo $myfile -sql "ALTER TABLE $name ADD COLUMN code_num integer(3)"
ogrinfo $myfile -dialect SQLite -sql "UPDATE $name SET code_num = CAST(code_06 As integer(3))"
Komunikat o błędzie:
Kay@KAY-PC /c/users/kay/desktop/bash
$ sh calc_field_shp.sh
INFO: Open of `extr_and_app.dbf'
using driver `ESRI Shapefile' successful.
INFO: Open of `extr_and_app.dbf'
using driver `ESRI Shapefile' successful.
ERROR 1: SQL Expression Parsing Error: syntax error
INFO: Open of `extr_and_app.dbf'
using driver `ESRI Shapefile' successful.