Bug#434897: v.db.update with 6.2.2 patch
On Wed, 2007-08-08 at 22:40 +0200, Markus Neteler wrote: 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 Hi Markus, The patch does not work : GRASS 6.2.2 (ALMERIA):~/projets/ucl/alert/alertprog/grass v.db.update map=base_cells column=irrigated value=b_irr_area * area_new\ / b_area_tot Sorry, q is not a valid flag Description: Outputs basic information about a user-specified vector map layer. Keywords: vector Usage: v.info [-hcg] map=name [layer=value] Flags: -h Print vector history instead of info -c Print types/names of table columns for specified layer instead of info -g Print vector map region only Parameters: map Name of input vector map layer Layer number default: 1 DBMI-Postgres driver error: Cannot execute: UPDATE base_cells SET irrigated='b_irr_area * area_new/ b_area_tot' ERROR: invalid input syntax for type double precision: b_irr_area * area_new/ b_area_tot ERROR: Error while executing: UPDATE base_cells SET irrigated='b_irr_area * area_new/ b_area_tot' Just removing the -q in the v.info line solved the problem and make it work. I've attached the running version. Didrik 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 - 1.6.4.5 +++ scripts/v.db.update/v.db.update 8 Aug 2007 20:39:11 - @@ -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 | 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 signature.asc Description: This is a digitally signed message part
Bug#434897: v.db.update with 6.2.2 patch
On Mon, Aug 20, 2007 at 11:01:34AM +0200, Didrik Pinte wrote: ... Just removing the -q in the v.info line solved the problem and make it work. I've attached the running version. Didrik Perfect. Updated upstream in 6.2-CVS (scheduled for GRASS 6.2.3). Thanks for testing, 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 -- -- To UNSUBSCRIBE, email to [EMAIL PROTECTED] with a subject of unsubscribe. Trouble? Contact [EMAIL PROTECTED]
Bug#434897: v.db.update with 6.2.2 patch
On Sun, 2007-08-05 at 11:06 +0200, Markus Neteler wrote: Hi Didrik, I have seen your bug report. http://bugs.debian.org/cgi-bin/bugreport.cgi?bug=434897 Find attached a patch, could you try and report back? thanks Markus Hi Markus, It seems i get the same error : GRASS 6.2.2 (ALMERIA):~/projets/ucl/alert/alertprog/grass v.db.addcol map=base_cells columns='pprivate DOUBLE PRECISION' GRASS 6.2.2 (ALMERIA):~/projets/ucl/alert/alertprog/grass v.db.update map=base_cells column=pprivate value=b_pump_priva * area_new / b_area_tot Sorry, - is not a valid flag Sorry, q is not a valid flag Description: Outputs basic information about a user-specified vector map layer. Keywords: vector Usage: v.info [-hcg] map=name [layer=value] Flags: -h Print vector history instead of info -c Print types/names of table columns for specified layer instead of info -g Print vector map region only Parameters: map Name of input vector map layer Layer number default: 1 DBMI-Postgres driver error: Cannot execute: UPDATE base_cells SET pprivate='b_pump_priva * area_new / b_area_tot' ERROR: invalid input syntax for type double precision: b_pump_priva * area_new / b_area_tot ERROR: Error while executing: UPDATE base_cells SET pprivate='b_pump_priva * area_new / b_area_tot' Can I test something else ? I'll be offline during the next three days. Cheers, Didrik -- Didrik Pinte [EMAIL PROTECTED] Information Technologies for the Agro-Environment signature.asc Description: This is a digitally signed message part
Bug#434897: v.db.update with 6.2.2 patch
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 - 1.6.4.5 +++ scripts/v.db.update/v.db.update 8 Aug 2007 20:39:11 - @@ -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