Using OLD on INSERT

Поиск
Список
Период
Сортировка
От Paul Makepeace
Тема Using OLD on INSERT
Дата
Msg-id 20040122132944.GN26240@mythix.realprogrammers.com
обсуждение исходный текст
Ответы Re: Using OLD on INSERT  (Terry Lee Tucker <terry@esc1.com>)
Re: Using OLD on INSERT  ("Marcus Andree S. Magalhaes" <marcus.magalhaes@vlinfo.com.br>)
Список pgsql-novice
I have a trigger that sets an expires column to
last_access+expiry::interval if expires IS NULL or if the expires value
isn't being set or changed.

  IF NEW.expires IS NULL OR NEW.expires = OLD.expires THEN
      NEW.expires = NEW.last_access+NEW.expiry:interval;
  END IF;

The problem here is OLD doesn't exist on the first INSERT which throws
an error. It seems PL/pgSQL doesn't have C's short-circuit booleans.

a) Is there a way around this?
b) is there a 'right' way to determine if a column is being changed?

Paul (total PL/pgSQL newbie)

--
Paul Makepeace ................................  http://paulm.com/ecademy

"If I had new shoes, then he wouldn't sing Halleighluha."
   -- http://paulm.com/toys/surrealism/

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

Предыдущее
От: Tom Lane
Дата:
Сообщение: Re: passwords
Следующее
От: Iandé Coutinho
Дата:
Сообщение: executing backup remotly