描述
返回给出其名称的SQL参数的索引。返回的索引值适用于sqlite3_bind_*函数的第二个参数。如果找不到匹配的参数,则返回零。
C / C ++语法
int sqlite3_bind_parameter_index( sqlite3_stmt*, const char *zName ); |
PB语法
FUNCTION sqlite3_bind_parameter_index ( _ BYVAL hStmt AS DWORD, _ BYREF szName AS ASCIIZ _ ) AS LONG |
参数
pStmt
[in]语句句柄。
szName
[in]参数名称。即使原始语句使用sqlite3_prepare16_v2从UTF-16文本准备,也必须以UTF-8给出。
返回值
参数的索引。
C ++实现代码
/*
** Given a wildcard parameter name, return the index of the variable
** with that name. If there is no variable with the given name,
** return 0.
*/
SQLITE_PRIVATE int sqlite3VdbeParameterIndex(Vdbe *p, const char *zName, int nName){
int i;
if( p==0 ){
return 0;
}
if( zName ){
for(i=0; i<p->nzVar; i++){
const char *z = p->azVar[i];
if( z && memcmp(z,zName,nName)==0 && z[nName]==0 ){
return i+1;
}
}
}
return 0;
}
SQLITE_API int sqlite3_bind_parameter_index(sqlite3_stmt *pStmt, const char *zName){
return sqlite3VdbeParameterIndex((Vdbe*)pStmt, zName, sqlite3Strlen30(zName));
}