On 19 Apr 2017, at 7:47pm, no...@null.net wrote: > I use > triggers quite heavily as a kind of stored procedure. > > Instead of basing them on views however I use real tables and AFTER > INSERT triggers whose final statement deletes the NEW row just > inserted. > > I see two benefits to the use of AFTER INSERT triggers: > > * Constraints are enforced so SQLite catches invalid > "procedure calls." > * Default values for columns (or "arguments") can be defined. This > is very useful if you want to use the incoming value in multiple > statements - you don't have to hardcode a bunch of > COALESCE(NEW.col, $DEFAULT) values everywhere.
Had you considered doing UPDATE instead of INSERT ? Leave one row in the table and issue an UPDATE command when you want to trigger a trigger. If the column you’re changing isn’t indexed it’s a little faster. And just like INSERT you can use the value you set, using CASE … END, to set what you want to happen. Simon. _______________________________________________ sqlite-users mailing list sqlite-users@mailinglists.sqlite.org http://mailinglists.sqlite.org/cgi-bin/mailman/listinfo/sqlite-users