[GRASS-user] exponentiation with v.db.update

Moritz Lennert mlennert at club.worldonline.be
Tue Jun 9 12:27:56 EDT 2009


On 09/06/09 17:56, A. Marcia BARBOSA wrote:
> Hi,
> I'm trying to populate a column with 10 raised to the power of the
> values in another column:
> 
> v.db.update map=ItaReg column=x qcolumn=10^logx
> 
> but I get a dbmi protocol error. I've tried using either single or
> double quotes with no success. If I use a combination of both, i.e.
> "qcolumn= ' 10^logx ' " it doesn't report any error, but doesn't do
> the operation either (the column remains unchanged).
> 
> It works fine for other operations (e.g. 10*logx), though. Is there
> another way in which I should specify the exponentiation?

Which db backend are you using ?

This works for me with a PostgreSQL database:

v.db.addcol ssbel_pg col="test double precision"
v.db.update ssbel_pg col=test value="cat^2" (or qcol="cat^2")

In PostgreSQL there is also power(a,b).

For SQLite the same function is available in the extension-functions.c 
available here:
http://sqlite.org/contrib/download/

Moritz


More information about the grass-user mailing list