What is the use of using sqlite3_data_count () over sqlite3_column_count () in the SQLite C API?

After reading the documents, it seems that the sqlite3_column_count function does the same, but does not have the limitations that sqlite3_data_count has.

Why would I like to use sqlite3_data_count over sqlite3_column_count? thank!

+3
source share
2 answers

sqlite3_data_countreturns the number of values ​​(columns) of the current executable statement. With no results, it returns 0.

sqlite3_column_countOn the other hand, it always returns the number of columns with or without results.

Which one you will use depends on whether you need to get the number of columns or not.

+4

:

/*
** 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;
}

, , NickD .

, : "sqlite3_data_count (P) P." , , , .

+12

Source: https://habr.com/ru/post/1731995/


All Articles