1.Dd $Mdocdate$ 2.Dt SQLITE3_CHANGES 3 3.Os 4.Sh NAME 5.Nm sqlite3_changes 6.Nd Count The Number Of Rows Modified 7.Sh SYNOPSIS 8.Ft int 9.Fo sqlite3_changes 10.Fa "sqlite3*" 11.Fc 12.Sh DESCRIPTION 13This function returns the number of database rows that were changed 14or inserted or deleted by the most recently completed SQL statement 15on the database connection specified by the first 16parameter. 17Only changes that are directly specified by the INSERT, UPDATE, 18or DELETE statement are counted. 19Auxiliary changes caused by triggers or foreign key actions 20are not counted. 21Use the sqlite3_total_changes() function to 22find the total number of changes including changes caused by triggers 23and foreign key actions. 24.Pp 25Changes to a view that are simulated by an INSTEAD OF trigger 26are not counted. 27Only real table changes are counted. 28.Pp 29A "row change" is a change to a single row of a single table caused 30by an INSERT, DELETE, or UPDATE statement. 31Rows that are changed as side effects of REPLACE constraint 32resolution, rollback, ABORT processing, DROP TABLE, or by 33any other mechanisms do not count as direct row changes. 34.Pp 35A "trigger context" is a scope of execution that begins and ends with 36the script of a trigger. 37Most SQL statements are evaluated outside of any trigger. 38This is the "top level" trigger context. 39If a trigger fires from the top level, a new trigger context is entered 40for the duration of that one trigger. 41Subtriggers create subcontexts for their duration. 42.Pp 43Calling sqlite3_exec() or sqlite3_step() 44recursively does not create a new trigger context. 45.Pp 46This function returns the number of direct row changes in the most 47recent INSERT, UPDATE, or DELETE statement within the same trigger 48context. 49.Pp 50Thus, when called from the top level, this function returns the number 51of changes in the most recent INSERT, UPDATE, or DELETE that also occurred 52at the top level. 53Within the body of a trigger, the sqlite3_changes() interface can be 54called to find the number of changes in the most recently completed 55INSERT, UPDATE, or DELETE statement within the body of the same trigger. 56However, the number returned does not include changes caused by subtriggers 57since those have their own context. 58.Pp 59See also the sqlite3_total_changes() interface, 60the count_changes pragma, and the changes() SQL function. 61.Pp 62If a separate thread makes changes on the same database connection 63while sqlite3_changes() is running then the value 64returned is unpredictable and not meaningful. 65.Sh SEE ALSO 66.Xr sqlite3 3 , 67.Xr sqlite3_changes 3 , 68.Xr sqlite3_exec 3 , 69.Xr sqlite3_step 3 , 70.Xr sqlite3_total_changes 3 71