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


--
Sent via pgsql-bugs mailing list (pgsql-bugs@postgresql.org)
To make changes to your subscription:
http://www.postgresql.org/mailpref/pgsql-bugs

Reply via email to