I'm writing three triggers in PL/pgSQL. In each case, I have a RECORD
variable and want to insert that into a table, delete it from the table, or update it to represent a second RECORD
variable.
Adding is easy: INSERT INTO mytable VALUES (NEW.*);
Deleting isn't as easy, there doesn't seem to be a syntax for something like this:
DELETE FROM mytable
WHERE * = OLD.*;
Updating has the same problem. Is there an easy solution, short of generating matching SQL queries that compare each attribute using ideas from this answer?