β οΈ This post links to an external website. β οΈ
A trigger lets you run an action when you
INSERT,UPDATEorDELETEa value.Today I wanted to write a value to a SQLite database, and error if the database already had a conflicting value.
There are a variety of ways you could do this β I decided to read the current stored value and check it in Go β but I also discovered thereβs a way you could do it in SQL alone using CREATE TRIGGER. I did this with SQLite, but it looks like this is supported by other SQL dialects, including PostgreSQL and MySQL.
continue reading on alexwlchan.net
If this post was enjoyable or useful for you, please share it! If you have comments, questions, or feedback, you can email my personal email. To get new posts, subscribe use the RSS feed.