[GRASS5] sql expression weirdnesses

Daniel Calvelo Aros dcalvelo at minag.gob.pe
Mon Jun 6 03:50:30 EDT 2005


Hi all,

I'm baffled by the following:

<session>
GRASS 6.0.0 (pe):~/t/ > db.select dist2002 sql="select cat from dist2002 where
(ALT_DIST < 500)" |wc #Ok.
     421     421    1809
GRASS 6.0.0 (pe):~/t/ > db.select dist2002 sql="select cat from dist2002 where
(ALT_DIST/2+ALT_DIST/2 < 500)" |wc #Ooops.
    1829    1829    8033
GRASS 6.0.0 (pe):~/t/ > db.select dist2002 sql="select cat from dist2002 where
(ALT_DIST*2 < 1000)" |wc #Ok
     421     421    1809
GRASS 6.0.0 (pe):~/t/ > db.select dist2002 sql="select cat from dist2002 where
(ALT_DIST+ALT_DIST < 1000)" |wc #Still ok.
     421     421    1809
GRASS 6.0.0 (pe):~/t/ > db.select dist2002 sql="select cat from dist2002 where
(ALT_DIST+ALT_DIST/2 < 750)" |wc #Still ok.
     421     421    1809
GRASS 6.0.0 (pe):~/t/ > db.select dist2002 sql="select cat from dist2002 where
(ALT_DIST/2+ALT_DIST < 750)" |wc #Ooops. Non-commuting sum
    1829    1829    8033
GRASS 6.0.0 (pe):~/t/ > db.select dist2002 sql="select cat from dist2002 where
((ALT_DIST/2)+ALT_DIST < 750)" |wc #Puzzled...
DBMI-DBF driver error:
SQL parser error in statement:
select cat from dist2002 where ((ALT_DIST/2)+ALT_DIST < 750)
Error in db_open_select_cursor()

       0       0       0
</session>

Is there a (hopefully documented) limitation in the sql parser that provokes
these things? Is it some NULL-related weirdness?

Background: I'm trying to implement expression themeing for d.vect.thematic. I
found that since expressions are allowed in where clauses, it is enough to
make v.univar.sh calculate correct statistics for expressions and then let the
sql parser deal with the corresponding expression. I'm stuck with behaviour as
exemplified above.

This is grass6 as in Lorenzo Moretti's distribution, unpatched, under MacOSX
10.3.9. FYI:

<session>
GRASS 6.0.0 (pe):~/t/thematic/d.vect.thematic > db.connect -p
driver:dbf
database:$GISDBASE/$LOCATION_NAME/$MAPSET/dbf/
schema:(null)
group:(null)
GRASS 6.0.0 (pe):~/t/thematic/d.vect.thematic > v.info -c dist2002
Displaying column type for database connection of layer 1:
INTEGER|CAT
CHARACTER|CODIGO_DEP
CHARACTER|NOMB_DEP
CHARACTER|CODIGO_PRO
CHARACTER|NOMB_PROV
CHARACTER|CODIGO_DIS
CHARACTER|NOMB_DIST
CHARACTER|DCTO
CHARACTER|LEY
CHARACTER|FECHA
CHARACTER|NOM_CAP
CHARACTER|CAT_CAP
INTEGER|ALT_DIST
CHARACTER|LAT_DIST
CHARACTER|LONG_DIST
CHARACTER|REG_NAT
CHARACTER|REGNAT2
INTEGER|UG_N
CHARACTER|grassrgb
</session>

Any hints?

Cheers,

Daniel.

-- Daniel Calvelo Aros




More information about the grass-dev mailing list