Referencing columns of the fly in triggers

Поиск
Список
Период
Сортировка
От James F
Тема Referencing columns of the fly in triggers
Дата
Msg-id 002f01c29fcd$074f1310$3b0010ac@jfreezexp
обсуждение исходный текст
Ответы Re: Referencing columns of the fly in triggers  (Darko Prenosil <darko.prenosil@finteh.hr>)
Список pgsql-general

I would like to know if there is any way to create a common ON UPDATE trigger function that can be called from any table and be able to figure out which field(s) changed. The difficulty is being able to reference at run time the column names of that table, short of hard-coding all of them. The new and old records allow you to reference the columns, but only if you already know the name of the column. Is there nothing equivalent to new[column_index] that would allow me to iterate through the columns without knowing beforehand the column names? And then, given a certain column index, to reference the name of that column?

The goal of this trigger is to log all UPDATES to an audit log table, so the table name, column name, and new column value are all needed to write to the change log. Is there a better way of doing this?

thanks for your help.

James F

В списке pgsql-general по дате отправления:

Предыдущее
От: "Robert Fitzpatrick"
Дата:
Сообщение: Field sizes and structure
Следующее
От: Mike Mascari
Дата:
Сообщение: Re: Is NULL equal to NULL or not?