-----BEGIN PGP SIGNED MESSAGE-----
Hash: SHA1

Wayne Anderson wrote:
> I'm unclear about several things, but chief among them is how to set  
> the initial size of a blob. 

If you are using SQL then use:

  INSERT into foo values(zeroblob(12345))

If you are using bindings with a statement like:

  INSERT into foo values(?)

Then use sqlite3_bind_zeroblob to set the size.  This effectively makes
the value be nulls/zero for whatever size you set.  Then use the
incremental blob api to read/write the contents of the blob as you deem fit.

> The documentation indicates that you need  
> to use the "UPDATE SQL Command" to change the size of a blob but I  
> have no idea how to do this from within a C/C++ program.

As you saw in the documentation the blob api does not allow for changing
the size of the blob.  You use the UPDATE command with zeroblobs as
shown in the insert stuff above to create a new blob of whatever size
you want.

Aside: You can do an append abusing || which returns a string and cast
it back to blob, but it is very hacky.  For example this will increase
the size by 2048 bytes:

  UPDATE foo SET x=CAST( x || zeroblob(2048) AS blob) WHERE ....

> Can anyone point me to some sample code?

Pretty much only the page you already read:

  http://www.sqlite.org/c3ref/blob_open.html

The functions are regular open/read/write/close with the proviso that
you can't change the blob size.  Also note what happens if the database
is altered while you have blobs open.  You use zeroblobs to efficiently
allocate the space for blobs.

Roger
-----BEGIN PGP SIGNATURE-----
Version: GnuPG v1.4.9 (GNU/Linux)

iEYEARECAAYFAkpWi+YACgkQmOOfHg372QRm4wCg2R6DNGpcwLiBVA2e/PNKXfRA
/n4AoJy8+G8jkij5ComIzZ0g+6m5KWmZ
=Chnh
-----END PGP SIGNATURE-----
_______________________________________________
sqlite-users mailing list
sqlite-users@sqlite.org
http://sqlite.org:8080/cgi-bin/mailman/listinfo/sqlite-users

Reply via email to