On Apr 13, 2009, at 2:14 PM, Julian Bui wrote: > Hi all, > > I have a question about encoding blob bytes before inserting a > record into > SQLite. > > CONTEXT: > I have a base java (I'm using JDBC) class that has a many children. > Each > child may store a different data type (such as String, int, long, > etc.) in > its VALUE field. Since this value field could be many different > data types, > I will be storing the field's bytes into the database as a blob.
Why? SQLite is perfectly capable of storing multiple datatypes in a single column. It sounds to me like you are making your problem much harder than it needs to be. > > > QUESTIONS: > > -I have seen a couple of places on the internet saying that SQLite > cannot > inserting binary data unless it has been encoded. Can someone > confirm this > or preferrably point me to an OFFICIAL sqlite statement/page saying > that > this is true? I'm not sure what you mean by "encoded". If you do: INSERT INTO sometable VALUES(?) And then bind a blob to the ?, you do not need to make any transformations to the blob ahead of time. On the other hand, if you say: INSERT INTO sometable VALUES(x'0123456789abcdef'); Then clearly you have had to convert your 8-byte blob into hexadecimal in order to insert it into the middle of your INSERT statement. The first technique (the use of ? and sqlite3_bind_blob()) is preferred since it is both faster and less error-prone. D. Richard Hipp d...@hwaci.com _______________________________________________ sqlite-users mailing list sqlite-users@sqlite.org http://sqlite.org:8080/cgi-bin/mailman/listinfo/sqlite-users