Hi Didrik,

oh - the --q in my patch should have been -q.

Attached the revised patch. Due to failing of v.info
the rest also fails (say, the new trick fails to
work around the indicated problem).

Let me know,
Markus

-- 
Markus Neteler  <neteler itc it>  http://mpa.itc.it/markus/
FBK-irst -  Centro per la Ricerca Scientifica e Tecnologica
MPBA - Predictive Models for Biol. & Environ. Data Analysis
Via Sommarive, 18        -       38050 Povo (Trento), Italy
New GRASS book: http://www.grassbook.org/

------------------
ITC -> dall'1 marzo 2007 Fondazione Bruno Kessler
ITC -> since 1 March 2007 Fondazione Bruno Kessler
------------------
Index: scripts/v.db.update/v.db.update
===================================================================
RCS file: /grassrepository/grass6/scripts/v.db.update/v.db.update,v
retrieving revision 1.6.4.5
diff -u -r1.6.4.5 v.db.update
--- scripts/v.db.update/v.db.update     15 May 2007 10:57:18 -0000      1.6.4.5
+++ scripts/v.db.update/v.db.update     8 Aug 2007 20:39:11 -0000
@@ -78,8 +78,12 @@
 LC_NUMERIC=C
 export LC_NUMERIC
 
-# does map exist?
-eval `g.findfile element=vector file=$GIS_OPT_MAP`
+### setup enviro vars ###
+eval `g.gisenv`
+: ${GISBASE?} ${GISDBASE?} ${LOCATION_NAME?} ${MAPSET?}
+
+# does map exist in CURRENT mapset?
+eval `g.findfile element=vector file=$GIS_OPT_MAP mapset=$MAPSET`
 if [ ! "$file" ] ; then
    echo "Vector map '$GIS_OPT_MAP' not found in mapset search path"
    exit 1
@@ -94,11 +98,20 @@
 database=`v.db.connect $GIS_OPT_MAP -g | grep -w $GIS_OPT_LAYER | awk '{print 
$4}'`
 driver=`v.db.connect $GIS_OPT_MAP -g | grep -w $GIS_OPT_LAYER | awk '{print 
$5}'`
 
+# checking column types
+coltype=`v.info -c map=$GIS_OPT_MAP -q | grep -w $GIS_OPT_COLUMN | cut -d'|' 
-f1`
+# we insert a value
+if [ "$coltype" = "INTEGER" -o "$coltype" = "DOUBLE PRECISION" ] ; then
+    value=$GIS_OPT_VALUE
+else
+    value=\'$GIS_OPT_VALUE\'
+fi
+
 if [ -n "$GIS_OPT_WHERE" ]
   then
-       echo "UPDATE $table SET $GIS_OPT_COLUMN='$GIS_OPT_VALUE' WHERE 
$GIS_OPT_WHERE" | db.execute database=$database driver=$driver
-  else
-       echo "UPDATE $table SET $GIS_OPT_COLUMN='$GIS_OPT_VALUE'" | db.execute 
database=$database driver=$driver
+       echo "UPDATE $table SET $GIS_OPT_COLUMN=$value WHERE $GIS_OPT_WHERE" | 
db.execute database=$database driver=$driver
+else
+       echo "UPDATE $table SET $GIS_OPT_COLUMN=$value" | db.execute 
database=$database driver=$driver
 fi
 
 exit 0

Reply via email to