Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Getting the number of affected rows for a SQLite statement using the C API

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.

like image 770
netcoder Avatar asked Jul 01 '11 18:07

netcoder


People also ask

How do I limit the number of rows in SQLite?

SQLite Limit: You can limit the number of rows returned by your SQL query, by using the LIMIT clause. For example, LIMIT 10 will give you only 10 rows and ignore all the other rows. In the LIMIT clause, you can select a specific number of rows starting from a specific position using the OFFSET clause.

How do I find the size of a SQLite table?

sqlite > dbinfo. sql will give you detail info on each table's size on disk.

What is sqlite3_step?

The sqlite3_step() runs the SQL statement. SQLITE_ROW return code indicates that there is another row ready. Our SQL statement returns only one row of data, therefore, we call this function only once. sqlite3_finalize(res); The sqlite3_finalize() function destroys the prepared statement object.


1 Answers

Try sqlite3_changes() and/or sqlite3_total_changes()

like image 68
Vinicius Kamakura Avatar answered Sep 21 '22 13:09

Vinicius Kamakura