Small. Fast. Reliable.
Choose any three.

About Sitemap Documentation Download License News Developers Support

## SQLite C Interface

## Data Change Notification Callbacks

>     void *sqlite3_update_hook(
>       sqlite3*,
>       void(*)(void *,int ,char const *,char const *,sqlite3_int64),
>       void*
>     );

The sqlite3_update_hook() interface registers a callback function with the database connection identified by the first argument to be invoked whenever a row is updated, inserted or deleted. Any callback set by a previous call to this function for the same database connection is overridden.

The second argument is a pointer to the function to invoke when a row is updated, inserted or deleted. The first argument to the callback is a copy of the third argument to sqlite3_update_hook(). The second callback argument is one of SQLITE_INSERT, SQLITE_DELETE, or SQLITE_UPDATE, depending on the operation that caused the callback to be invoked. The third and fourth arguments to the callback contain pointers to the database and table name containing the affected row. The final callback parameter is the rowid of the row. In the case of an update, this is the rowid after the update takes place.

The update hook is not invoked when internal system tables are modified (i.e. sqlite_master and sqlite_sequence).

The update hook implementation must not do anything that will modify the database connection that invoked the update hook. Any actions to modify the database connection must be deferred until after the completion of the sqlite3_step() call that triggered the update hook. Note that sqlite3_prepare_v2() and sqlite3_step() both modify their database connections for the meaning of "modify" in this paragraph.

If another function was previously registered, its pArg value is returned. Otherwise NULL is returned.

### Invariants:

H12971 | The sqlite3_update_hook(D,F,P) interface causes the callback function F to be invoked with first parameter P whenever a table row is modified, inserted, or deleted on the database connection D.
H12973 | The sqlite3_update_hook(D,F,P) interface returns the value of P for the previous call on the same database connection D, or NULL for the first call.
H12975 | If the update hook callback F in sqlite3_update_hook(D,F,P) is NULL then the no update callbacks are made.
H12977 | Each call to sqlite3_update_hook(D,F,P) overrides prior calls to the same interface on the same database connection D.
H12979 | The update hook callback is not invoked when internal system tables such as sqlite_master and sqlite_sequence are modified.
H12981 | The second parameter to the update callback is one of SQLITE_INSERT, SQLITE_DELETE or SQLITE_UPDATE, depending on the operation that caused the callback to be invoked.
H12983 | The third and fourth arguments to the callback contain pointers to zero-terminated UTF-8 strings which are the names of the database and table that is being updated.
H12985 | The final callback parameter is the rowid of the row after the change occurs.

See also lists of Objects, Constants, and Functions.

This page last modified 2008/12/09 18:44:04 UTC