5

sqlite3_get_table is defined as below:

int sqlite3_get_table(
  sqlite3 *db,          /* An open database */
  const char *zSql,     /* SQL to be evaluated */
  char ***pazResult,    /* Results of the query */
  int *pnRow,           /* Number of result rows written here */
  int *pnColumn,        /* Number of result columns written here */
  char **pzErrmsg       /* Error msg written here */
);

As it said in the document, it can get a result table convenient and is implemented as a wrapper around sqlite3_exec().

But it is now not recommended:

This is a legacy interface that is preserved for backwards compatibility. Use of this interface is not recommended.

But if I use sqlite3_exec, I need to write a extra callback function. It is more complex。</p>

So my question is what the main problem of this interface is? Why it need to be deprecated?

For more information see http://www.sqlite.org/c3ref/free_table.html.

4

1 回答 1

5

问题sqlite3_get_table是所有值都转换为字符串,并且必须为所有结果记录分配内存。

您应该使用sqlite3_prepare_v2 / sqlite3_step / sqlite3_column_xxx / sqlite3_finalize函数。

于 2013-02-28T09:15:36.750 回答