[GRASS-user] db.execute: SELECT STATEMENT

Wolf Bergenheim wolf+grass at bergenheim.net
Tue Jan 30 08:31:12 EST 2007


Markus Neteler wrote:
> Right - which is confusing since the module says:
> "db.execute  - Execute any SQL statement"
> apparently wrong? Or a bug?

This is a case of programing technique showing in the UI. Normally in 
programming with databases, there are two kind of queries you can give 
to a database. All (well almost, there might be some exception) DB APIs 
give the programmer 2 functions execute and select. The select function 
usually return a dataset - the response to the query, while the execute 
just returns a success flag, since this function is used to execute 
statements like UPDATE, DELETE, INSERT etc. A good UI would hide this 
distinction based on the query.

> For now, just use db.select instead.
> But we should solve this confusion.
>> I add, that combination can be execute in pgadmin without problem so 
>> statements are good
> It seems to be a (mysterious to me) limitation in db.execute.

So either fix db.execute to call a select function instead, or even 
db.select if it gets a SELECT statement to execute? Otherwise fix 
documentation, meaning that the manual and help should say "...EXECUTE 
any non-SELECT statement. Use db.select to execute SELECT statements." 
Or something like that.

--Wolf

-- 

<:3 )---- Wolf Bergenheim ----( 8:>




More information about the grass-user mailing list