Kit wrote:
> 2012/5/13, Frank Chang <frank_chan...@hotmail.com>:
>> Here is another way I found out how insert UTF-8 strings in SQLITE3.EXE.
>>
>> F:\sqlite3_6_16>sqlite3.exe mdName.dat
>> SQLite version 3.6.16
>> Enter ".help" for instructions
>> Enter SQL statements terminated with a ";"
>> sqlite> INSERT INTO PREFIX SELECT CAST(x'52C3B373' AS TEXT),'M','Ros','10';
>> sqlite> .quit                                        
> 
> sqlite> CREATE TABLE PREFIX (a TEXT, b TEXT, c TEXT, d INT);
> sqlite> INSERT INTO PREFIX SELECT CAST(x'52C3B373' AS TEXT),'M','Ros','10';
> sqlite> INSERT INTO PREFIX SELECT x'52C3B373','M','Ros','10';
> sqlite> INSERT INTO PREFIX VALUES (x'52C3B373','M','Ros','10');
> sqlite> SELECT * FROM PREFIX;
> Rós|M|Ros|10
> Rós|M|Ros|10
> Rós|M|Ros|10

While they look similar at first, they are actually different:
sqlite> SELECT TYPEOF(a), LENGTH(a) FROM prefix;
text|3
blob|4
blob|4

And in sqlite CAST (and other expressions) can be used with INSERT VALUES too:
sqlite> INSERT INTO PREFIX VALUES (CAST(x'52C3B373' AS TEXT),'M','Ros','10');
(resulting in correct 'text|3' row).

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

Reply via email to