SQLiteCpp
SQLiteCpp copied to clipboard
how to detect change or udpate column in table
i want to fire event after change or update column in table sqlite3_update_hook , is any solution please thanks
@bnadem Can you elaborate on your requirements? It sounds like you want a trigger, which could be implemented via calling db.exec() on at CREATE TRIGGER sqlite statement.
An example CREATE TRIGGER statement might look like this:
CREATE TRIGGER add_change_to_foo_audit_log
AFTER UPDATE ON list_of_foos
WHEN old.foo_col <> new.foo_col
BEGIN
INSERT INTO foo_audit_log (
old_id,
new_id,
old_foo_col,
new_foo_col,
created_at
)
VALUES
(
old.id,
new.id,
old.foo_col,
new.foo_col,
DATETIME('NOW')
) ;
END;
Then you would call db.exec() to execute it on the database.