Sean Moss-Pultz wrote: > Hi List > > Here's basically what I'm doing: > > sqlite> create table test(t text); > sqlite> insert into test values(0123); > sqlite> select * from test; > 123 > > How can I get the string to stay 0123? I've read the docs about > "Column Affinity." But I guess I'm not smart enough to figure this out > :-) > > 0123 is a numeric literal, in which leading zeros aren't significant. So 0123 = 123, which gets converted to the string '123'. > BTW, I can't put the number into quotes first because that would break > my code, at a later point, when I handle this value. IE, the user > could insert '0123' (string) or 0123 (number). I need these to stay > unique. > Then you shouldn't be using a TEXT-affinity column, because all your numbers will get converted to strings. And INTEGER, REAL, and NUMERIC affinities won't work for the opposite reason. So you need to use the NONE affinity, i.e., a declared type of "BLOB".
sqlite> create table test(t blob); sqlite> insert into test values(0123); sqlite> insert into test values('0123'); sqlite> select t, typeof(t) from test; 123|integer 0123|text (BTW, is there a way to get the command-line interface to quote strings?) _______________________________________________ sqlite-users mailing list sqlite-users@sqlite.org http://sqlite.org:8080/cgi-bin/mailman/listinfo/sqlite-users