Reputation: 1491
I've been looking for a way to get the names of any modified columns during an INSERT inside a trigger function. I can get the table modified using the trigger procedure TG_TABLE_NAME, is there anything similar for modified columns?
Upvotes: 2
Views: 867
Reputation: 325241
No, there is no equivalent to TG_TABLE_NAME
for column names. You need to compare the old
and new
records in an UPDATE
trigger.
For INSERT
triggers the idea of "modified" column names doesn't even make any sense. Do you mean columns that are not at their default values?
Anyway, you need to examine the NEW
and (where it applies) OLD
records. This can be tricky to do dynamically. The hstore
extension is often the most useful tool, as it allows you to do comparisons between and iterations over columns of unknown rowsets.
Upvotes: 1