Re: UNIQUE_VIOLATION exception, finding out which index would have been violated

Поиск
Список
Период
Сортировка
От Michael Fuhr
Тема Re: UNIQUE_VIOLATION exception, finding out which index would have been violated
Дата
Msg-id 20070925074328.GA60682@winnie.fuhr.org
обсуждение исходный текст
Ответ на UNIQUE_VIOLATION exception, finding out which index would have been violated  (Petri Simolin <petrisimolin@petrisimolin.com>)
Список pgsql-general
On Tue, Sep 25, 2007 at 04:55:37AM -0200, Petri Simolin wrote:
> I have created a function which inserts a row in a table which has 2 unique
> indexes on two different columns.
>
> I am wondering, if there is a way in case of UNIQUE_VIOLATION exception to
> find out which index would have been violated?

In PL/pgSQL you could extract the constraint name from SQLERRM,
which should be a string like 'duplicate key violates unique
constraint "foo_id1_key"'.

--
Michael Fuhr

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

Предыдущее
От: "Ashish Karalkar"
Дата:
Сообщение: PgpoolAdmin installation
Следующее
От: Devrim GÜNDÜZ
Дата:
Сообщение: Re: PgpoolAdmin installation