Re: INSERT OR UPDATE

Поиск
Список
Период
Сортировка
От Tony Wasson
Тема Re: INSERT OR UPDATE
Дата
Msg-id 6d8daee30601022202g42666269ue144b28dab28ff4@mail.gmail.com
обсуждение исходный текст
Ответ на INSERT OR UPDATE  ("Julian Scarfe" <julian@avbrief.com>)
Список pgsql-general
On 1/2/06, Julian Scarfe <julian@avbrief.com> wrote:
> I'm keeping config information for an application in a series of related
> tables.  I'd like a command that INSERTs data if it's new, or UPDATEs it if
> the key is duplicated.

A MERGE trigger will do exactly what you are asking for.

http://archives.postgresql.org/pgsql-sql/2004-05/msg00135.php

Send all your data as INSERTS.
The trigger will run a function to see if the row exists.
If the row exists -> rewrite it as it as an UPDATE
If the row does not exist -> leave the INSERT alone

Tony

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

Предыдущее
От: Lucky Leavell
Дата:
Сообщение: Re: Ident authentication failed
Следующее
От: Andrew - Supernews
Дата:
Сообщение: Re: INSERT OR UPDATE