views:

937

answers:

2

I have an sqlite table that contains a BLOB file, but need to do a size/length check on the blob, how do I do that?

According to some documentation I did find, using length(blob) won't work, because length() only works on texts and will stop counting after the first NULL. My empirical tests have shown this to be true.

I'm using SQLite 3.4.2

+4  A: 

haven't had this problem, but you could try length(hex(glob))/2

Javier
Yep thats it! thanks.
Petriborg
A: 

for me length(blob) works just fine, gives the same results like the other.

Chris
For a binary blob? That would be in violation of the SQLite documentation which says blobs are treated as text and as such length() is accurate only until it finds a `\0` character.
Petriborg