On 2/17/16, Glyn Jones <glynj at bsquare.com> wrote:
> My code behaves differently:
> % package require sqlite3
> 3.8.11.1
> % sqlite3 db :memory:
> % db eval {CREATE TABLE users(id,name);}
> % set id "???"
> ???
> % db eval {insert into users (id, name) values (:id,:id)}
> % db eval {select hex(id) from users}
> C382C2ACC382C2ACC382C2AC
> %
>

You must be running on windows.  This is a case of TCL converting the
content of the script file as it reads it in to execute it.

I suggest you work around the problem by using only ASCII characters
in your TCL script, and using \u0000 escapes for any unicode
characters you need.

To verify, try adding "puts [string length $id]" to the script, and
see that it does indeed show $id set to a 6-character string.

package require sqlite3
sqlite3 db :memory:
db eval {CREATE TABLE users(id,name);}
set id "???"
puts [string length $id]
set name whatever
db eval {insert into users (id, name) values (:id, :name)}
puts [db eval {SELECT hex(id) FROM users}]


-- 
D. Richard Hipp
drh at sqlite.org

Reply via email to