[GRASS-SVN] r31583 - grass/trunk/scripts/v.db.join

svn_grass at osgeo.org svn_grass at osgeo.org
Fri May 30 09:15:34 EDT 2008


Author: neteler
Date: 2008-05-30 09:15:34 -0400 (Fri, 30 May 2008)
New Revision: 31583

Modified:
   grass/trunk/scripts/v.db.join/v.db.join
Log:
don't add if col already there

Modified: grass/trunk/scripts/v.db.join/v.db.join
===================================================================
--- grass/trunk/scripts/v.db.join/v.db.join	2008-05-30 12:41:24 UTC (rev 31582)
+++ grass/trunk/scripts/v.db.join/v.db.join	2008-05-30 13:15:34 UTC (rev 31583)
@@ -103,10 +103,14 @@
 
 i=1
 for col in $COLLIST ; do
-  v.db.addcol "$GIS_OPT_MAP" col="$col `echo $COLTYPES | cut -d' ' -f$i | tr -s '_' ' '`"
+  # col already there?
+  v.info --quiet -c map="$GIS_OPT_MAP" layer=$GIS_OPT_LAYER | cut -d'|' -f1,2 | grep "|${col}$" 2>&1 >/dev/null
   if [ $? -ne 0 ] ; then
+     v.db.addcol "$GIS_OPT_MAP" col="$col `echo $COLTYPES | cut -d' ' -f$i | tr -s '_' ' '`"
+     if [ $? -ne 0 ] ; then
 	g.message -e "Cannot continue."
 	exit 1
+     fi
   fi
   echo "UPDATE $maptable SET $col=(SELECT $col
         FROM $GIS_OPT_otable WHERE $GIS_OPT_otable.$GIS_OPT_ocolumn=$maptable.$GIS_OPT_column);" | db.execute



More information about the grass-commit mailing list