Re: 'UPDATE OR INSERT' command

Поиск
Список
Период
Сортировка
От Bruno Wolff III
Тема Re: 'UPDATE OR INSERT' command
Дата
Msg-id 20040715175318.GA18875@wolff.to
обсуждение исходный текст
Ответ на 'UPDATE OR INSERT' command  (Jeff Kowalczyk <jtk@yahoo.com>)
Список pgsql-sql
On Thu, Jul 15, 2004 at 13:20:57 -0500, Jeff Kowalczyk <jtk@yahoo.com> wrote:
> Is there a postgresql SQL idiom to perform an UPDATE, which becomes an
> INSERT if the primary key does not exist?
> 
> I'm not sure I *should* use it in my application, I just want to know if
> it can be done. Thanks.

There isn't a single statement that does this.

This has been discussed a number of times. The archives will have some
different examples.

You end up needing to either lock the table or check for failure since
postgres doesn't have predicate locking. Which technique is best will
depend on the details of your situation.


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

Предыдущее
От: Jeff Kowalczyk
Дата:
Сообщение: 'UPDATE OR INSERT' command
Следующее
От: Stephen Frost
Дата:
Сообщение: Re: 'UPDATE OR INSERT' command