Consider the following two (hypothetical) tables
Temperature
* day
* time
* lake_name
* station
* temperature_f
Temperature_summary
* day
* lake_name
* station
* count_readings_over_75f
* count_readings_below_75f
How can I write an SQLite Trigger to update the temperature_summary table on insert. I want to increment the count.
Thank You,
Jeff
This assumes you have already created the record for the day/lake_name/station before inserting temperatures on that day. Of course, you could add another trigger to do that.
You can combine these into one slightly more complex trigger
To insure that there is a row in Temperature_summary to update (a) make a unique index on Temperature_summary’s
(day, lake_name, station), or make those columns the primary key, and (b) do an insert or ignore in the trigger like so: