After reading the docs, it seems the the function sqlite3_column_count does all the same, but doesn't have the restrictions that sqlite3_data_count has.
Why would I ever want to use sqlite3_data_count over sqlite3_column_count? thanks!
I've looked up the sources of the two functions:
/*
** Return the number of columns in the result set for the statement pStmt.
*/
SQLITE_API int sqlite3_column_count(sqlite3_stmt *pStmt){
Vdbe *pVm = (Vdbe *)pStmt;
return pVm ? pVm->nResColumn : 0;
}
/*
** Return the number of values available from the current row of the
** currently executing statement pStmt.
*/
SQLITE_API int sqlite3_data_count(sqlite3_stmt *pStmt){
Vdbe *pVm = (Vdbe *)pStmt;
if( pVm==0 || pVm->pResultSet==0 ) return 0;
return pVm->nResColumn;
}
Now it is clear what the difference is, so NickD was right.
By the way, the documentation is horrible: "The sqlite3_data_count(P) the number of columns in the of the result set of prepared statement P." That's not even correct English, the comments that come with the function definitions are much better.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With