Looking at the sqlite3_update_hook function, it gives the callback a database, table and rowid, but how does one retrieve the row data (for insert/update changes)?
One may think that you can just do a SELECT query to retrieve the data, but the documentation seems to suggest that you cannot run queries from the callback. Scheduling this query after you've finished the update seems a little counter-productive too, as it somewhat negates the merits of a callback function.
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.
It seems like retrieving the row information would be a typical thing to do from an update hook. What is the correct way to do it?
The update hook is not designed to do anything with the data itself.
To get at the old/new values, call a user-defined function from a trigger.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With