[ACCEPTED]-Can I update New in before insert trigger in sqlite?-sqlite
Accepted answer
No, you can't update NEW.
What I tend to 7 do is use a VIEW with an INSTEAD OF trigger 6 as mu is to short commented.
In your case 5 the best solution may be to use an AFTER 4 INSERT/UPDATE trigger WHEN NEW.t IS NULL 3 to update t in the affected row(s):
CREATE TRIGGER test_in
AFTER INSERT ON test
FOR EACH ROW
WHEN (NEW.t IS NULL)
BEGIN
UPDATE test SET t = now() WHERE id = NEW.id;
END;
FYI, your 2 id
column should probably be declared as INTEGER 1 PRIMARY KEY...
Source:
stackoverflow.com
More Related questions
Cookie Warning
We use cookies to improve the performance of the site. By staying on our site, you agree to the terms of use of cookies.