Oops, I should have said old instead of new in a couple of places: > begin immediate > ; > create table "Capacity Statistics" > ( ID integer primary key unique references "Capacity" (ID) on delete > cascade > , Count integer not null > ) > ; > insert into "Capacity Statistics" (ID, Count) select Capacity_ID, count(*) > from "Movie People" group by Capacity_ID having Count > 0 > ; > create trigger "Movie People insert" > on "Movie People" > after insert > begin > insert or replace into "Capacity Statistics" (ID, Count) > select new.Capacity_ID, (select coalesce(Count, 0) + 1 from "Capacity > Statistics" where ID = new.Capacity_ID) > ; > end > ; > create trigger "Movie People delete" > on "Movie People" > after insert > begin > insert or replace into "Capacity Statistics" (ID, Count) > select new.Capacity_ID, (select coalesce(Count, 0) - 1 from "Capacity > Statistics" where ID = old.Capacity_ID)
Should be: select old.Capacity_ID, (select coalesce(Count, 0) - 1 from "Capacity Statistics" where ID = old.Capacity_ID) > ; > end > ; > create trigger "Movie People update" > on "Movie People" > after update of Capacity_ID > begin > insert or replace into "Capacity Statistics" (ID, Count) > select new.Capacity_ID, (select coalesce(Count, 0) + 1 from "Capacity > Statistics" where ID = new.Capacity_ID) > ; > insert or replace into "Capacity Statistics" (ID, Count) > select new.Capacity_ID, (select coalesce(Count, 0) - 1 from "Capacity > Statistics" where ID = old.Capacity_ID) Should be: select old.Capacity_ID, (select coalesce(Count, 0) - 1 from "Capacity Statistics" where ID = old.Capacity_ID) > ; > end > ; > commit > ; Thanks, Tom BareFeetWare -- Comparison of SQLite GUI tools: http://www.barefeetware.com/sqlite/compare/?ml _______________________________________________ sqlite-users mailing list sqlite-users@sqlite.org http://sqlite.org:8080/cgi-bin/mailman/listinfo/sqlite-users