| From: | Petr Jelinek <pjmodos(at)pjmodos(dot)net> |
|---|---|
| To: | PostgreSQL-development <pgsql-hackers(at)postgresql(dot)org> |
| Subject: | Re: UPSERT |
| Date: | 2007-03-04 15:06:05 |
| Message-ID: | 45EAE05D.9080004@pjmodos.net |
| Views: | Whole Thread | Raw Message | Download mbox | Resend email |
| Thread: | |
| Lists: | pgsql-hackers |
Bruno Wolff III wrote:
> On Sun, Mar 04, 2007 at 14:55:47 +0200,
> Hannu Krosing <hannu(at)skype(dot)net> wrote:
>> UPDATE
>> IF NOT FOUND THEN
>> INSERT
>> IF DUPLICATE KEY THEN
>> UPDATE
>> END IF
>> END IF
>
> I believe it is possible for the above to fail. For example another
> transaction could create a matching record between the update and insert
> and then another transaction could delete it between the insert and the
> second update.
You know we have example in manual right ?
http://www.postgresql.org/docs/current/static/plpgsql-control-structures.html#PLPGSQL-UPSERT-EXAMPLE
:)
--
Regards
Petr Jelinek (PJMODOS)
| From | Date | Subject | |
|---|---|---|---|
| Next Message | Martijn van Oosterhout | 2007-03-04 15:49:49 | Re: UPSERT |
| Previous Message | Hannu Krosing | 2007-03-04 13:54:54 | Re: UPSERT |