sqlite-API-sqlite3_get_table()

來源:互聯網
上載者:User

標籤:

參考--http://www.cnblogs.com/likebeta/archive/2012/06/17/2552784.html

http://babybandf.blog.163.com/blog/static/61993532010326133751/

執行sql語句

得到結果集,並儲存

無回呼函數

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 */);void sqlite3_free_table(char **result);

第1個參數不再多說,看前面的例子。
第2個參數是sql 語句,跟sqlite3_exec 裡的sql 是一樣的。是一個很普通的以\0結尾的char*字串。
第3個參數是查詢結果,它依然一維數組(不要以為是二維數組,更不要以為是三維數組)。它記憶體布局是:欄位名稱,後面是緊接著是每個欄位的值。下面用例子來說事。
第4個參數是查詢出多少條記錄(即查出多少行,不包括欄位名那行)。
第5個參數是多少個欄位(多少列)。
第6個參數是錯誤資訊,跟前面一樣,這裡不多說了。
pazResult返回的字串數量實際上是(*pnRow+1)*(*pnColumn),因為前(*pnColumn)個是欄位名



sqlite-API-sqlite3_get_table()

聯繫我們

該頁面正文內容均來源於網絡整理,並不代表阿里雲官方的觀點,該頁面所提到的產品和服務也與阿里云無關,如果該頁面內容對您造成了困擾,歡迎寫郵件給我們,收到郵件我們將在5個工作日內處理。

如果您發現本社區中有涉嫌抄襲的內容,歡迎發送郵件至: info-contact@alibabacloud.com 進行舉報並提供相關證據,工作人員會在 5 個工作天內聯絡您,一經查實,本站將立刻刪除涉嫌侵權內容。

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.