描述
此函数用于移动现有的blob句柄,使其指向同一数据库表的不同行。新行由作为第二个参数传递的rowid值标识。只有行可以改变。blob句柄打开的数据库,表和列保持不变。将现有的blob句柄移动到新行可能比关闭现有句柄并打开新行更快。
C / C ++语法
int sqlite3_blob_reopen(sqlite3_blob *, sqlite3_int64); |
PB语法
FUNCTION sqlite3_blob_reopen ( _ BYVAL pBlob AS DWORD, _ BYVAL qRow AS QUAD _ ) AS LONG |
参数
pBlob
[in]blob句柄。
qRiw
[in]行??号。
返回值
SQLITE_OK成功或错误代码如果出现问题。此函数设置数据库句柄错误代码和消息。
备注
新行必须符合与sqlite3_blob_open相同的条件 - 它必须存在,并且必须存在指定列中的blob或文本值。如果新行不在表中,或者不包含blob或文本值,或者如果发生另一个错误,则返回一个SQLite错误代码,并且该Blob句柄被视为已中止。在中止的blob句柄上的所有后续调用sqlite3_blob_read,sqlite3_blob_write或sqlite3_blob_reopen立即返回SQLITE_ABORT。在中止的blob句柄上调用sqlite3_blob_bytes总是返回零。
C ++实现代码
/*
** Move an existing blob handle to point to a different row of the same
** database table.
**
** If an error occurs, or if the specified row does not exist or does not
** contain a blob or text value, then an error code is returned and the
** database handle error code and message set. If this happens, then all
** subsequent calls to sqlite3_blob_xxx() functions (except blob_close())
** immediately return SQLITE_ABORT.
*/
SQLITE_API int sqlite3_blob_reopen(sqlite3_blob *pBlob, sqlite3_int64 iRow){
int rc;
Incrblob *p = (Incrblob *)pBlob;
sqlite3 *db;
if( p==0 ) return SQLITE_MISUSE_BKPT;
db = p->db;
sqlite3_mutex_enter(db->mutex);
if( p->pStmt==0 ){
/* If there is no statement handle, then the blob-handle has
** already been invalidated. Return SQLITE_ABORT in this case.
*/
rc = SQLITE_ABORT;
}else{
char *zErr;
rc = blobSeekToRow(p, iRow, &zErr);
if( rc!=SQLITE_OK ){
sqlite3Error(db, rc, (zErr ? "%s" : 0), zErr);
sqlite3DbFree(db, zErr);
}
assert( rc!=SQLITE_SCHEMA );
}
rc = sqlite3ApiExit(db, rc);
assert( rc==SQLITE_OK || p->pStmt==0 );
sqlite3_mutex_leave(db->mutex);
return rc;
}