[GRASS-user] Rename multiple sqlite columns at once
Nikos Alexandris
nikos.alexandris at felis.uni-freiburg.de
Wed Nov 5 13:51:46 EST 2008
On Wed, 2008-11-05 at 19:36 +0100, Nikos Alexandris wrote:
> On Wed, 2008-11-05 at 17:33 +0100, Moritz Lennert wrote:
> > On 05/11/08 15:17, Nikos Alexandris wrote:
> > > On Tue, 2008-11-04 at 10:35 +0100, Paolo Craveri wrote:
[...]
I tried another example using "cut" this time.
----
#!/bin/sh
CAT="cat"
PREFIX="tmp_"
for COLUMN in `db.columns test`; do
if [ "$COLUMN" != "$CAT" ]; then
PRETEMP=`echo $COLUMN | awk '{print tolower($1)}'`
TEMP=$PREFIX$PRETEMP
v.db.renamecol map=test layer=1 column=$COLUMN,$TEMP
lower_column=`echo $TEMP | cut -d"_" -f2`
v.db.renamecol map=test layer=1 column=$TEMP,
$lower_column
fi
done
db.columns test
----
It works (final columns are renamed/reported all with lower case letters
by db.columns) BUT it produces lots of errors? Is this a bug? Below the
details:
#initial test vector map
db.columns test
block_id
cat
AREA
PERIMETER
RAS2X2_
RAS2X2_ID
RAS2X2_NR
block
STAND
BEFL_DATUM
BEFL_JAHR
QUALITAET
# running the "cut" script
sh ./caps_2_lower_cut.sh
DBMI-SQLite driver error:
Error in sqlite3_prepare():
duplicate column name: block
ERROR: Error while executing: 'ALTER TABLE test ADD COLUMN block INTEGER
'
ERROR: Cannot continue (problem adding column).
ERROR: Cannot continue (problem renaming column)
DBMI-SQLite driver error:
Error in sqlite3_prepare():
duplicate column name: ras2x2
ERROR: Error while executing: 'ALTER TABLE test ADD COLUMN ras2x2 DOUBLE
PRECISION
'
ERROR: Cannot continue (problem adding column).
ERROR: Cannot continue (problem renaming column)
DBMI-SQLite driver error:
Error in sqlite3_prepare():
duplicate column name: ras2x2
ERROR: Error while executing: 'ALTER TABLE test ADD COLUMN ras2x2
varchar(1)
'
ERROR: Cannot continue (problem adding column).
ERROR: Cannot continue (problem renaming column)
WARNING: SQLite driver: unable to parse decltype: CHARACTER INTEGER
WARNING: SQLite driver: unable to parse decltype: CHARACTER INTEGER
WARNING: SQLite driver: column 'tmp_block', SQLite type 1 is not
supported
WARNING: SQLite driver: unable to parse decltype: CHARACTER INTEGER
WARNING: SQLite driver: unable to parse decltype: CHARACTER INTEGER
WARNING: SQLite driver: column 'tmp_block', SQLite type 1 is not
supported
ERROR: Column <tmp_block> not found in table
DBMI-SQLite driver error:
Error in sqlite3_prepare():
duplicate column name: befl
ERROR: Error while executing: 'ALTER TABLE test ADD COLUMN befl INTEGER
'
ERROR: Cannot continue (problem adding column).
ERROR: Cannot continue (problem renaming column)
cat
tmp_block_id
area
perimeter
ras2x2
tmp_ras2x2_id
tmp_ras2x2_nr
stand
befl
tmp_befl_jahr
qualitaet
More information about the grass-user
mailing list