You could've tested this in the time it took for you to get answer: File x.sql PRAGMA foreign_keys=OFF; BEGIN TRANSACTION; CREATE TABLE t (i integer); INSERT INTO "t" VALUES(1); CREATE TABLE c(i integer); CREATE TRIGGER t1 before insert on t begin insert into c values((select count(*) from t));end; CREATE TRIGGER t2 after insert on t begin insert into c values((select count(*) from t));end; COMMIT; SQLite version 3.6.23.1 Enter ".help" for instructions Enter SQL statements terminated with a ";" sqlite> .read x.sql sqlite> insert into t values(2); sqlite> select * from c; 1 2 Michael D. Black Senior Scientist Advanced Analytics Directorate Northrop Grumman Information Systems
________________________________ From: sqlite-users-boun...@sqlite.org on behalf of Tim Romano Sent: Tue 8/3/2010 6:53 AM To: General Discussion of SQLite Database Subject: EXTERNAL:Re: [sqlite] How to write the trigger? Is a to-be-inserted row supposed to be included among the counted rows in a BEFORE INSERT trigger? Could you end up with 5 rows? What happens if you make this an AFTER trigger? _______________________________________________ sqlite-users mailing list sqlite-users@sqlite.org http://sqlite.org:8080/cgi-bin/mailman/listinfo/sqlite-users
_______________________________________________ sqlite-users mailing list sqlite-users@sqlite.org http://sqlite.org:8080/cgi-bin/mailman/listinfo/sqlite-users