[GRASSLIST:10450] SQL commands

jessi jessi_issej at hotmail.com
Mon Feb 20 15:20:21 EST 2006


hello.
i am trying to use SQL commands to manipulate my dbf table. i thought i could do
this either with db.execute or the SQL parameter to ogr2ogr or ogrinfo. when i
run db.test under grass, it correctly executes various SQL commands, such as 
select * from grass_test1
and 
update grass_test1 set d1 = 18.6, i2 = 987  where i1 = 2
however, i get errors with the SQL parser when i try to do the same commands
myself. i am able to create a table, insert values & insert columns using
db.execute, but when i try to select, i get this error:

db.execute driver=dbf database=/home/jessi/GRASSDATA/location/jessi/dbf
input=/home/jessi/moreGrass/commands3.sql 
dbmi: Protocol error (invalid table/column name or unsupported column type)

GRASS_INFO_ERROR(14902,1): Error while executing: "select * from grass_test1"

i am using the same SQL commands which db.test uses---is there any reason why it
would respond differently? 

i have also tried to input sql commands using ogrinfo, and have similar
problems. for example, if give the command:
ogrinfo /home/jessi/moreGrass streetcl -sql 'SELECT * FROM streetcl'

i get this feedback:
INFO: Open of `/home/jessi/moreGrass'
using driver `ESRI Shapefile' successful.
layer names ignored in combination with -sql.
ERROR 1: SQL: Missing FROM clause in SELECT statement.

it seems to be unable to parse the command. 

i am hoping to join tables using sql commands like:

UPDATE streetcl SET ELEVFROM=(SELECT ELEV FROM intersect WHERE
intersect.STREETCL_=streetcl.FNODE_)

or

SELECT streetcl.*, intersect.ELEV FROM streetcl LEFT JOIN intersect ON
streetcl.FNODE_ =intersect.STREETCL_

are there other ways to do this? 
thanks very much,
jessi




More information about the grass-user mailing list