Reputation: 29
Please I need a help in SQLite trigger: I want to fire the trigger after insert on a table and insert some values automatically into another table I have used this statement and it works but how can use it in a trigger
INSERT INTO student_score SELECT tk.cpr,s.Student_name, sum (sp.score), tk.test_taken_id
FROM student s, student_paper sp,test_taken tk
where s.cpr=tk.cpr
and tk.test_taken_id=sp.test_taken_id
group by tk.test_taken_id;
I hope that I explained clearly thank you
Upvotes: 2
Views: 10498
Reputation: 17929
documentation here: http://www.sqlite.org/lang_createtrigger.html
CREATE TRIGGER customTrigger
AFTER INSERT ON student_score
FOR EACH ROW
BEGIN
INSERT INTO newTable (col1, col2) VALUES ("value1", "value2")
END;
this should work. Do the necessary changes to fit your needs. Hope it helps, regards
Upvotes: 2