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

chandan wrote:
>     ret = sqlite3_bind_zeroblob(stmt, 2, -1);

That binds zero length blob (last parameter being zero or negative).

>     ret = sqlite3_bind_blob(stmt, 2, blob, 0, SQLITE_TRANSIENT);

That binds a zero length blob, asking SQLite to make a copy of the first
zero bytes.

So there is no difference in effect of either statement.  The general
advice is to use sqlite3_bind_blob when you already have the entire blob
at hand in memory.

If you don't have the whole blob in memory at once (or don't want it all
in memory at once) then use sqlite3_bind_zeroblob giving the size of the
full blob.  After having completed the statement execution you can then
use the incremental Blob I/O to write the blob in parts.

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

As an example if you wanted to copy the contents of a 100MB file into a
SQLite database you could do one of these:

1 - Open file, read all 100MB into memory, use sqlite3_bind_blob

2 - Use sqlite3_bind_zeroblob with a size parameter of 100MB.  After the
statement has completed, use the blob i/o api to open it and open the
file.  Copy data from the file to the blob in 64kb chunks.  Close the
file and the blob.

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

iEYEARECAAYFAkokEWsACgkQmOOfHg372QTxcQCfeHajHeJfSnD81vzk1/tdmNz3
Pt8An2PJiXrv941swNJLH3DaUH1CPlHt
=+uoU
-----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