| От | Mike Nolan |
|---|---|
| Тема | TG_OP and undefined OLD values |
| Дата | |
| Msg-id | 200508261549.j7QFn9Rf016956@gw.tssi.com обсуждение |
| Ответы |
Re: TG_OP and undefined OLD values
|
| Список | pgsql-general |
I'm trying to write some code in a trigger that fires on both an insert
and an update.
At one point I need to update a column either on an insert or if the
value of the column has changed.
The following code fails because the OLD value is not defined:
if TG_OP = ''INSERT''
or (TG_OP = ''UPDATE'' and NEW.column1 != coalesce(OLD.column1,''--'')) then
column2 := ''CHANGED'';
end if;
Shouldn't OLD.column1 not even be evaluated when the other if statement in
the group in parentheses is false or when the earlier if statement is true?
Is there a way around this other than separating the code into two
independent if statements, duplicating the action statements?
--
Mike Nolan
В списке pgsql-general по дате отправления:
Сайт использует файлы cookie для корректной работы и повышения удобства. Нажимая кнопку «Принять» или продолжая пользоваться сайтом, вы соглашаетесь на их использование в соответствии с Политикой в отношении обработки cookie ООО «ППГ», в том числе на передачу данных из файлов cookie сторонним статистическим и рекламным службам. Вы можете управлять настройками cookie через параметры вашего браузера