Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Get number of columns in SQLite result

Tags:

c++

c

sql

sqlite

d

Well, this should be ultra-simple, but I simply can't seem to spot it among the 1001 sqlite-related commands.

So :

  • I'm performing a SELECT statement, with sqlite3_prepare
  • I'm getting the results per row with sqlite3_step
  • I'm accessing the Xth's column's result by sqlite3_column_text(sqlStmt,X)

The question is :

How can I get the number of columns in the row? (= the range in which X can... move...)


P.S. The question is tagged with d (I'm basically developing in D), but it won't make much difference since it's using native C bindings...

like image 255
Dr.Kameleon Avatar asked Nov 15 '25 12:11

Dr.Kameleon


1 Answers

According to http://www.sqlite.org/c3ref/data_count.html,

int sqlite3_data_count(sqlite3_stmt *pStmt);

returns the number of columns in the current row of the result set of prepared statement pStmt.

like image 174
Martin R Avatar answered Nov 18 '25 05:11

Martin R



Donate For Us

If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!