On Jul 8, 2008, at 11:21 AM, John Petrangelo wrote: > I am using the C/C++ API for sqlite. I am using sqlite3_bind_blob() to > insert data into the DB. The call typically looks like the following: > > > > rv = sqlite3_bind_blob(pStmt, 3, pBuffer, bufLen, > SQLITE_TRANSIENT); > > > > For my purposes, I prefer that these empty blobs be stored in the DB > as > "" (i.e. zero length data) rather than NULL. However, if pBuffer NULL > and bufLen is 0, then the bind assigns the NULL value. I have found > that > if pBuffer is non-NULL and bufLen is zero that the DB will store the > empty value we want. As a result, I've resorted to coding as follows: > > > > if (pBuffer != NULL) { > > rv = sqlite3_bind_blob(pStmt, 3, pBuffer, bufLen, > SQLITE_TRANSIENT); > > } else { > > rv = sqlite3_bind_blob(pStmt, 3, (void*)1, 0, > SQLITE_TRANSIENT); > > } >
Perhaps the statement would read better as follows: rv = sqlite3_bind_blob(pStmt, 3, "", 0, SQLITE_TRANSIENT); D. Richard Hipp [EMAIL PROTECTED] _______________________________________________ sqlite-users mailing list sqlite-users@sqlite.org http://sqlite.org:8080/cgi-bin/mailman/listinfo/sqlite-users