5 ms·
I was really hoping for statement level instead of triggers. SQL Server has them and they're extremely useful.
by nickpeterson 11y ago
I was really hoping for statement level instead of triggers. SQL Server has them and they're extremely useful.
- anarazel 11y agoI don't think anybody has expressed desire for that feature in a visible way, and I'm quite certain nobody is publicly working on it. While that'll likely not trigger anybody to just work on it, I invite you to send an email explaining what you want. Helps see a couple of those to gauge interest.
- netcraft 11y agoI'd love to hear about how you use instead of triggers. I can imagine some useful scenarios for them, but they seem so easily abused ive never really tried them.
- anarazel 11y agoRow-Level INSTEAD OF triggers are really useful to make views updateable that are otherwise too complicated to be updateable.
- rpedela 11y agoI think I am missing something. Statement level for what?
- tbrownaw 11y agocreate trigger tgr_whatever INSTEAD OF {update,insert,delete} on some_complex_view [for each row] <code goes here> Sometimes, if you run a DML statement on a view, the database can figure out how to translate that into DML on the underlying tables. Sometimes it can't. In this case the view is not updateable, unless you define appropriate "instead of" triggers on it. Some databases allow you do define these as statement-level triggers, that is without the "for each row" part. In that case the trigger will be passed all of the affected rows at once.
- anarazel 11y agoSo far postgres' statement level triggers do not have access to changed rows so far, be it an INSTEAD OF or any other kind of trigger. There has been some noise towards supporting it for AFTER triggers - I doubt we'll see BEFORE support, it's unclear to me what that'd even mean.
- rpedela 11y agoI see now. When I read it initially, I read it as "statement level ______ instead of triggers" rather than "statement level INSTEAD OF triggers". I thought a word was missing. Thanks!