updateHookCallBack



The updateHookCallBack method is an example of a user callback method for the updateHook method. Here the method name of updateHookCallBack is used, because it is the default method name if the programmer does not specify his own name in the updateHook method. Any method name can be used by specifying it as the second argument to the updateHook method.

Note: there is no updateHookCallBack method in any ooSQLite class. This method is just used to illustrate how to define a user callback method to be used with the update hook.

Arguments: The arguments sent to the callback method are:
op [required] One of 3 authorizer Authorizer Action Constants that indicate what the update operation was. Either INSERT, DELETE, or UPDATE.
dbName [required] The database Database Name of the database containing the affected row.
tableName [required] The table name of the table containing the affected row.
rowID [required] The row ID of the affected row. Every row of every SQLite table has a whole number key that uniquely identifies the row within its table. In the case of an update, this is the rowid after the update takes place.
userData [required] The user data object specified by the programmer as the third argument to theupdateHookmethod. If the programmer did not specify a user data argument, this will be the .nilobject.
Return value: The programmer must return a whole number value from the callback. However, the actual value returned makes no difference to the SQLite database engine. Typically, the programmer would just return 0.
Remarks: The callback method must not do anything that will modify the database connection that invoked the callback. Any actions to modify the database connection must be deferred until after the completion of the step invocation that triggered the update hook to begin with. Running any other SQL statements, including SELECT statements, or merely instantiating a new new (Class method) object, or executing anotherstepmethod will modify the database connection. The update hook is not invoked when internal SQLite system tables are modified (i.e. sqlite_master and sqlite_sequence). In the current SQLite database enginge implementation, the update hook is not invoked when duplicate rows are deleted because of an ON CONFLICT REPLACE clause. Nor is the update hook invoked when rows are deleted using the truncate optimization. The exceptions defined in this paragraph might change in a future release of SQLite.
Details: The implementation of aupdate hookmethod is is discussed on the SQLite sqlite3_update_hook page.