[GRASS-dev] Re: [GRASS-user] v.db.join script
Moritz Lennert
mlennert at club.worldonline.be
Mon Oct 18 10:58:04 EDT 2010
On 13/10/10 22:23, Micha Silver wrote:
> One line from the v.db.join script uses grep and cut to get the column
> names and the next line gets the column types like so:
>
> db.describe -c bike_rides2 | grep '^Column' | cut -d ':' -f 3
> INTEGER
> CHARACTER
> INTEGER
> CHARACTER
> CHARACTER
> CHARACTER
> CHARACTER
>
> So the column size is actually ignored.
>
> Next, in the script the above output is used by v.db.addcol to create
> the new columns in the joined vector. So all new character columns are
> created as a single char and the actual length is never used.
>
> Questions:
> Is the db.describe output the same for all db drivers?
> Any suggestions how to fix this as a script?
Why not use an SQL join, i.e. something like the following ?
1) CREATE TABLE temp AS (SELECT * FROM $maptable JOIN $otable ON
$column=$ocolumn)
2) rename table $maptable to something else
3) rename table temp to $maptable
4) if this works, remove the original $maptable
Not tested, but might be a more elegant solution ?
Moritz
More information about the grass-user
mailing list