Re: Conditional INSERT: if not exists

Поиск
Список
Период
Сортировка
От Sean Davis
Тема Re: Conditional INSERT: if not exists
Дата
Msg-id 44EB060D.3090606@mail.nih.gov
обсуждение исходный текст
Ответ на Conditional INSERT: if not exists  ("Don Morrison" <donmorrison@gmail.com>)
Ответы Re: Conditional INSERT: if not exists  ("Don Morrison" <donmorrison@gmail.com>)
Re: Conditional INSERT: if not exists  ("Don Morrison" <donmorrison@gmail.com>)
Список pgsql-novice
Don Morrison wrote:
> I want to insert a row unless it exists already.  Do I have to write a
> stored procedure to do this?

Hi, Don.

Just do the insert.  If it already exists, it simply isn't inserted.
You will, of course, receive an error that the row exists, but that
isn't a problem.  If you need to do this in a transaction, you can
simply set savepoints and roll back to the savepoint if an insert fails
(and you expected that it could).

Sean

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

Предыдущее
От: "Don Morrison"
Дата:
Сообщение: Conditional INSERT: if not exists
Следующее
От: "Phillip Smith"
Дата:
Сообщение: Re: Conditional INSERT: if not exists