Having used the Tcl interface to SQLite for 10+ years I was caught out when
accessing someone else's DB. I don't see a satisfactory way to fix it, but
a warning would help.

Example to illustrate:

sqlite3 dbcmd grbg.db
package require sqlite3
dbcmd eval {create table a (Xyz text)}
dbcmd eval {insert into a (xyz) values ('z')}
dbcmd eval {insert into a (XYZ) values ('y')}
dbcmd eval {insert into a (XyZ) values ('x')}

dbcmd eval "select xyz from a"    {  puts "$xyz"  }        ;#== gives
error: can't read "xyz": no such variable
dbcmd eval "select xyz from a" v {  puts "$v(xyz)" }     ;#== gives error:
can't read "v(xyz)": no such element in array

dbcmd eval "select xyz as xyz from a"  { puts $xyz }    ;#== ouput is as
expected
z
y
z

Apparently the TCL variable names set by "eval' are in the same case as the
column names orginally defined in the CREATE statement* unless an alias is
used.*

In the docs ( http://www.sqlite.org/tclsqlite.html ) this section on "eval"
has a paragraph which begins:

If the array variable name is omitted or is the empty string, then the
> value of each column is stored in a variable with the same name as the
> column itself.
>

Perhaps a warning could be added like "The case of the variable is the same
as in the table definition unless a column alias is used."

John Gillespie
_______________________________________________
sqlite-users mailing list
sqlite-users@mailinglists.sqlite.org
http://mailinglists.sqlite.org/cgi-bin/mailman/listinfo/sqlite-users

Reply via email to