Re: BUG #5081: ON INSERT rule does not work correctly

Поиск
Список
Период
Сортировка
От Jacques Caron
Тема Re: BUG #5081: ON INSERT rule does not work correctly
Дата
Msg-id 20090928141310.E384F35A28BB@zeus.directinfos.com
обсуждение исходный текст
Ответ на BUG #5081: ON INSERT rule does not work correctly  ("Stefan" <sb@drbott.de>)
Ответы Re: BUG #5081: ON INSERT rule does not work correctly  (Robert Haas <robertmhaas@gmail.com>)
Список pgsql-bugs
Hi,

You can use a trigger before insert and a pl/pgsql function that goes:

BEGIN
  UPDATE table SET ... WHERE pk=NEW.pk
  IF FOUND THEN
   RETURN NULL;
  ELSE
   RETURN NEW;
  END IF;
END;

Jacques.

At 19:36 27/09/2009, Robert Haas wrote:
>Sometimes when I've needed to do this I've written a PL/pgsql function
>that tries the insert and then fails over to an UPDATE if the INSERT
>fails due to a unique-violation.  I'm not sure that's 100% robust
>either, though, unless using serializable mode.
>
>...Robert
>
>--
>Sent via pgsql-bugs mailing list (pgsql-bugs@postgresql.org)
>To make changes to your subscription:
>http://www.postgresql.org/mailpref/pgsql-bugs

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

Предыдущее
От: Stefan Bähring
Дата:
Сообщение: Re: BUG #5081: ON INSERT rule does not work correctly
Следующее
От: Heikki Linnakangas
Дата:
Сообщение: Re: BUG #5084: Query gives different number of rows depending on ORDER BY