[GRASS-SVN] r50590 - grass/branches/develbranch_6/scripts/v.db.join

svn_grass at osgeo.org svn_grass at osgeo.org
Tue Jan 31 11:15:03 EST 2012


Author: lucadelu
Date: 2012-01-31 08:15:03 -0800 (Tue, 31 Jan 2012)
New Revision: 50590

Modified:
   grass/branches/develbranch_6/scripts/v.db.join/v.db.join
Log:
fix problems with -c flag

Modified: grass/branches/develbranch_6/scripts/v.db.join/v.db.join
===================================================================
--- grass/branches/develbranch_6/scripts/v.db.join/v.db.join	2012-01-31 14:56:30 UTC (rev 50589)
+++ grass/branches/develbranch_6/scripts/v.db.join/v.db.join	2012-01-31 16:15:03 UTC (rev 50590)
@@ -122,25 +122,35 @@
 COLTYPES=`db.describe -c driver="$driver" database="$database" table="$GIS_OPT_OTABLE" | grep '^Column ' | cut -d':' -f3 | tr -s ' ' '_'`
 
 i=1
+
+echo $GIS_FLAG_C;
+echo " $GIS_OPT_OCOLUMN";
+
 for col in $COLLIST ; do
-    if [ "$GIS_FLAG_C" -eq 1 ] && [ "$col" = "$GIS_OPT_COLUMN" ] ; then
-	continue
+    if [ "$GIS_FLAG_C" -eq 1 ] && [ "$col" = "$GIS_OPT_OCOLUMN" ] ; then
+        continue
     elif [ "$GIS_FLAG_A" -eq 1 ] ; then
-	col="${col}_o"
+        col="${col}_other"
     fi
+    if [ "$GIS_FLAG_C" -eq 1 ] && [ "$col" = "$GIS_OPT_OCOLUMN" ] ; then
+        continue
+    else
+        v.db.addcol "$GIS_OPT_MAP" layer="$GIS_OPT_LAYER" \
+        col="$col `echo $COLTYPES | cut -d' ' -f$i | tr -s '_' ' '`"
+    fi
 
-    v.db.addcol "$GIS_OPT_MAP" layer="$GIS_OPT_LAYER" \
-      col="$col `echo $COLTYPES | cut -d' ' -f$i | tr -s '_' ' '`"
-
     if [ $? -ne 0 ] ; then
-	g.message -e "Column creation failed. Cannot continue."
-	exit 1
+        g.message -e "Column creation failed. Cannot continue."
+        exit 1
     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 database="$database" driver="$driver"
-
+	
+    if [ "$GIS_FLAG_C" -eq 1 ] && [ "$col" = "$GIS_OPT_OCOLUMN" ] ; then
+    	continue
+    else
+        echo "UPDATE $maptable SET $col=(SELECT $col
+                FROM $GIS_OPT_OTABLE WHERE $GIS_OPT_OTABLE.$GIS_OPT_OCOLUMN=$maptable.$GIS_OPT_COLUMN);" | \
+        db.execute database="$database" driver="$driver"
+    fi
   i=`expr $i + 1`
 done
 



More information about the grass-commit mailing list