19

I'm executing a DELETE statement using the SQLite 3 C API, and I'd like to know how to fetch the number of affected rows.

Unfortunately, there is no function such as sqlite3_affected_rows or similar.

Brian Tompsett - 汤莱恩
  • 5,753
  • 72
  • 57
  • 129
netcoder
  • 66,435
  • 19
  • 125
  • 142

2 Answers2

19

Try sqlite3_changes() and/or sqlite3_total_changes()

Vinicius Kamakura
  • 7,665
  • 1
  • 29
  • 43
8

Run this.

select changes(),total_changes();

The changes() function returns the number of database rows that were changed or inserted or deleted by the most recently completed INSERT, DELETE, or UPDATE statement

The total_changes() function returns the number of row changes caused by INSERT, UPDATE or DELETE statements since the current database connection was opened.

(emphasis added)

Luc
  • 5,339
  • 2
  • 48
  • 48
Hakan
  • 240
  • 3
  • 4