Re: [sqlite] Before Insert/Update Trigger

2018-04-02 Thread petern
Hi Thomas. Below is a toy "records" table example which illustrates the INSTEAD OF pattern. --- CREATE TABLE records(rowid INTEGER PRIMARY KEY, data INTEGER, change_date TEXT DEFAULT CURRENT_TIMESTAMP); CREATE VIEW instead_of_records AS SELECT * FROM records; CREATE TRIGGER

Re: [sqlite] Before Insert/Update Trigger

2018-04-01 Thread petern
Thomas, SQLite has the INSTEAD OF trigger to intercept/modify/compose NEW values: https://www.sqlite.org/lang_createtrigger.html#instead_of_trigger I've found most situations are well handled by the INSTEAD OF trigger. It is powerful and somewhat comparable in functionality to stored procedure

[sqlite] Before Insert/Update Trigger

2018-03-31 Thread Thomas Kurz
Other DBMS support the following construct in a trigger: CREATE TRIGGER name BEFORE UPDATE ON table FOR EACH ROW BEGIN SET NEW.column = anyvalue END; In SQLite, the NEW record appearently is read-only. Support for changeable NEW records would however be graceful as it automatically prevents