I'm creating a trigger using SQLite and I want to compare if the OLD value is different than the NEW value so I can execute an INSERT
This is the trigger I created but seems like the MySQL syntax does not work in SQLite. What would be the equivalent?
CREATE TRIGGER document_handler AFTER UPDATE ON document
FOR EACH ROW
BEGIN
IF NEW.type <> OLD.type THEN
INSERT INTO DocumentUpdates (id_document, attribute_changed, lastvalue, newvalue, modification_date)
VALUES (id, "type", OLD.type, NEW.type, NOW());
END IF;
IF NEW.title <> OLD.title THEN
INSERT INTO DocumentUpdates (id_document, attribute_changed, lastvalue, newvalue, modification_date)
VALUES (id, "title", OLD.title, NEW.title, NOW());
END IF;
IF NEW.path <> OLD.path THEN
INSERT INTO DocumentUpdates (id_document, attribute_changed, lastvalue, newvalue, modification_date)
VALUES (id, "path", OLD.path, NEW.path, NOW());
END IF;
END;