Oops didn't read your other comment:

> 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.


Are you talking about the column affinity option?

-Julian

On Mon, Apr 13, 2009 at 11:41 AM, Julian Bui <[email protected]> wrote:

> By encoding I mean using some function to transform my binary data in such
> a way that removes the terminators and single quote characters.  However,
> from what you said, it sounds like I do not need to worry about encoding.
>
> I am using  ...VALUES(?) in a prepared statement and I will be using either
> .setBytes() or .setBlob() in my JDBC driver.  And again, it sounds like I
> will not need to encode, from your reply.
>
> Thanks,
> Julian
>
>
> On Mon, Apr 13, 2009 at 11:26 AM, D. Richard Hipp <[email protected]> wrote:
>
>>
>> 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
>> [email protected]
>>
>>
>>
>> _______________________________________________
>> sqlite-users mailing list
>> [email protected]
>> http://sqlite.org:8080/cgi-bin/mailman/listinfo/sqlite-users
>>
>
>
_______________________________________________
sqlite-users mailing list
[email protected]
http://sqlite.org:8080/cgi-bin/mailman/listinfo/sqlite-users

Reply via email to