[GRASS-user] Re: [GRASS-dev] trying to update column with another text column

Moritz Lennert mlennert at club.worldonline.be
Wed Apr 4 08:47:07 EDT 2012


On 04/04/12 08:33, Moritz Lennert wrote:
> On 04/04/12 08:02, Michael Barton wrote:
>> I want to update a column with the value of another column. I am using
>> v.db.update.
>>
>> The docs say that I can update a column with the value of another column
>> by specifying that column in the value field. In fact, if I put the
>> names of numeric columns, this works fine (e.g., v.db.update
>> map=myvector layer=1 column=summary value=col3 + col4).
>>
>> But if I do something like this for a string column, I simply get the
>> string of the name of the column (e.g., v.db.update map=myvector layer=1
>> column=summary value=col5 put "col5" into the summary column, NOT the
>> strings that are STORED in col5).
>>
>> Are the docs wrong or is this a bug?
>
> When the column to update is a string column, the script surrounds the
> value given with the value= parameter with quotes. It could check
> whether the given value is a column name and then not quote it but then
> again, how can we know that the person does not what to just fill a
> column with a string that corresponds to the name of another column ?
>
> Try using the qcolumn parameter.
>
> So docs should be updated to reflect that.

How about:

Index: v.db.update.py
===================================================================
--- v.db.update.py	(révision 51255)
+++ v.db.update.py	(copie de travail)
@@ -33,12 +33,12 @@
  #%option
  #% key: value
  #% type: string
-#% description: Value to update the column with, can be (combination 
of) other column(s)
+#% description: Value to update the column with
  #% required: no
  #%end
  #%option G_OPT_DB_COLUMN
  #% key: qcolumn
-#% description: Name of attribute column to query
+#% description: Name of other attribute column to query, can be 
combination of columns (e.g. co1+col2)
  #%end
  #%option G_OPT_DB_WHERE
  #%end
Index: v.db.update.html
===================================================================
--- v.db.update.html	(révision 51255)
+++ v.db.update.html	(copie de travail)
@@ -1,8 +1,8 @@
  <h2>DESCRIPTION</h2>

  <em>v.db.update</em> allows to assign a new value to a column in the
-attribute table connected to a given map. Alternatively, values can be
-copied from another column in the table.
+attribute table connected to a given map. The <em>value</em> parameter 
allows updating with a literal value. Alternatively, with the 
<em>qcol</em> parameter values can be
+copied from another column in the table or be the result of a 
combination or transformation of other columns.

  <h2>NOTES</h2>


?

Moritz


More information about the grass-user mailing list