Health Data Clinic - Book 13: Triggers & Stored Logic
Some SQL should run without anyone typing it. Triggers do exactly that, firing the moment data changes, and this book builds them properly. You create an audit table and then wire it up, AFTER INSERT first, then AFTER UPDATE and AFTER DELETE, until an audit trail is filling itself as you work. BEFORE triggers come next, used to validate a value before it is allowed into the table, together with the NEW and OLD keywords that let a trigger see what changed. A timing table lays out every combination in one place so you can pick the right one. The second half covers stored logic: stored procedures and why SQLite handles them differently from other database engines, and common table expressions with WITH as the lighter way to name and reuse query logic. A chapter on avoiding trigger loops keeps your automation from setting itself off, and a quick reference closes the book.
Twenty-five A4 pages, in full color. Written in short sentences and plain English, for readers whose first language is not English and clearer for everyone else because of it.
Every query in this book was run against a live database before the page was printed, so the result you read is the result you get. Instant PDF download. By M.R. Sterling.