[GRASSLIST:6722] Re: how to get other cats into other columns with v.to.db?!?!

Dan Jacobson jidanni at jidanni.org
Thu May 5 21:03:55 EDT 2005


Radim> You can upload a result of query in different layer using qlayer and
Radim> qcolumn.

But the man page says: "'qlayer' is used for area category query",
and I have lines, no?

And there are no query examples on the man page.

v.to.db map=i2 qlayer=2 qcolumn=contour option=query
ERROR: This option requires one column
v.to.db map=i2 qlayer=2 column=contour option=query
ERROR: Database connection not defined for layer <2>. Use v.db.connect
       first.
v.db.connect map=i2 table=vcvc layer=2
v.to.db map=i2 qlayer=2 column=contour option=query #qcolumn=contour
Querying database ... DBMI-DBF driver error:
SQL parser error in statement:
SELECT (null) FROM vcvc WHERE cat = 28
Error in db_open_select_cursor()

Who knows what you are talking about. Not me.
Useless. Document it if not.
All mumbo jumbo. Never mind. One can only do:
$ v.category input=i2 option=print layer=1,2|perl -nwe \
'm/(\d+)\|(\d+)/;\
printf "UPDATE vcvc SET contour=%d WHERE cat=%d;\n",\
$2,$1'|db.execute

GRASS 6.0.0 (2005)

Wait. I figured it out, with no help from the non documentation.
v.db.connect -o map=i2 table=vcvc layer=2
v.to.db map=i2 qlayer=2 column=contour option=query qcolumn=cat

OK, but actually I want to put twice the value into the table,
$ v.category input=i2 option=print layer=1,2|perl -nwe \
'm/(\d+)\|(\d+)/;\
printf "UPDATE vcvc SET contour=%d WHERE cat=%d;\n",\
$2*2,$1'|db.execute #Works, but let's try it the "smart" way:

$ ...
ERROR: Error while executing: UPDATE vcvc SET contour=(contour + contour)
ERROR: Error while executing: UPDATE vcvc SET contour=(contour * 2)

Anyways, you guys are in your own undocumented world.

ERROR: Error while executing: UPDATE vcvc SET contour=contour

Uh oh.

Wait,
$ echo UPDATE vcvc SET contour=1|db.execute
Works.  Great.  Wonderful.  Never mind.

What I am trying to say is "With meager documentation, nobody will
understand how to use your programs." "Yes I could help write
documentation, but, one problem: I don't understand how to use your
programs."

And if you think
       qcolumn=string
              Query  column  used  for 'query' option. E.g. 'cat', 'count(*)',
              'sum(val)'
sounds like legal column names, well it doesn't to we unwashed folk.
Obviously again some undocumented functionality only available to
those "in the know" who have access to secret v.to.db examples.
On the other hand, if even 2 + 2 produces an error, these probably
don't work either.




More information about the grass-user mailing list