/* $Revision: 14 $*/ CREATE TABLE entry (key integer primary key autoincrement, shoppinglistKey integer, productKey integer, BrowserId, status varchar(1), modified bigint, Description, shopKey bigint); CREATE TABLE modified (objectId,maxmodi bigint); CREATE TABLE "shop" (key integer primary key autoincrement, shoppinglistKey integer, globalId , Description, status varchar(1), modified bigint, browserId); CREATE TABLE shoppinglist (key integer primary key autoincrement,name); CREATE TRIGGER entry_insert_modified after insert on entry for each row Begin update modified set maxmodi=maxmodi + 1 where objectId='Entry'; select case WHEN changes() = 0 THEN raise (ABORT,'No entry in modified table for Entry, run statement insert into modified (objectId,maxmodi) values (''Entry'',0)') END; update entry set modified = (select maxmodi from modified where objectId='Entry') where rowid = new.rowid; End; CREATE TRIGGER entry_update_modified after update on entry for each row BEGIN update modified set maxmodi=maxmodi + 1 where objectId='Entry'; select case WHEN changes() = 0 THEN raise (ABORT,'No entry in modified table for Entry, run statement insert into modified (objectId,maxmodi) values (''Entry'',0)') END; update entry set modified = (select maxmodi from modified where objectId='Entry') where rowid = new.rowid; End; CREATE TRIGGER shop_insert_modified after insert on shop for each row Begin update modified set maxmodi=maxmodi + 1 where objectId='Shop'; select case WHEN changes() = 0 THEN raise (ABORT,'No entry in modified table for Shop, run statement insert into modified (objectId,maxmodi) values (''Shop'',0)') END; update shop set modified = (select maxmodi from modified where objectId='Shop') where rowid = new.rowid; End; CREATE TRIGGER shop_update_modified after update on shop for each row Begin update modified set maxmodi=maxmodi + 1 where objectId='Shop'; select case WHEN changes() = 0 THEN raise (ABORT,'No entry in modified table for Shop, run statement insert into modified (objectId,maxmodi) values (''Shop'',0)') END; update shop set modified = (select maxmodi from modified where objectId='Shop') where rowid = new.rowid; End;