Hello,
   Sorry this took some time to create a test case for...


----- Original Message ----
> From: Richard Hipp <d...@sqlite.org>
> Sent: Wed, June 8, 2011 7:14:40 AM
> Subject: Re: [sqlite] Tcl: $ and @
> 
> On Wed, Jun 8, 2011 at 6:37 AM, Edward Brekelbaum <nedb...@yahoo.com> wrote:
>>  Hello,
>>   Let me start by saying using SQLite in Tcl is a real  pleasure!
>>
>> I am having a problem determining when to use  $ and when to use @ (and
>> maybe I should use :, but I haven't  tried it).
> 
> You should always use $, except when you want to  insert a blob when you
> might consider using @, though $ will likely work in  that case too.
> 
> @ should only be used in the rare case when you have a TCL  variable that has
> both a string representation and a bytearray representation  and you want to
> use the bytearray representation and insert it as a  blob.

I have discovered my problem is with comparisons between integer and string.

package require sqlite3
sqlite db test.db
db eval {CREATE TABLE t1(x, data) }
db eval {INSERT INTO t1 VALUES('0', 'cheese')}
db eval {INSERT INTO t1 VALUES('four', 'bread')}

set x 0
db eval {SELECT * FROM t1 WHERE x=$x}
# returns empty string
set x four
db eval {SELECT * FROM t1 WHERE x=$x}
# returns "four bread"

Do I need to put types on the columns?  Or is casts a better way to go?

Thanks!
Ned
_______________________________________________
sqlite-users mailing list
sqlite-users@sqlite.org
http://sqlite.org:8080/cgi-bin/mailman/listinfo/sqlite-users

Reply via email to