Re: Question about catching exception

Поиск
Список
Период
Сортировка
От tv@fuzzy.cz
Тема Re: Question about catching exception
Дата
Msg-id decfe71cc7af426aa9d0a4e80559a354.squirrel@sq.gransy.com
обсуждение исходный текст
Ответ на Re: Question about catching exception  (Pavel Stehule <pavel.stehule@gmail.com>)
Список pgsql-general
> Hello
>
> you have to parse a sqlerrm variable

That's one way to do that. Another - more complex but more correct in many
cases is using two separate blocks.

BEGIN
   ... do stuff involving constraint A
EXCEPTION
   WHEN unique_violation THEN ...
END;

BEGIN
   ... do stuff involving constraint B
EXCEPTION
   WHEN unique_violation THEN ...
END;

But that's not possible if there are two unique constraints involved in a
single SQL statement (e.g. inserting into a table with two unique
constraints).

regards
Tomas


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

Предыдущее
От: Pavel Stehule
Дата:
Сообщение: Re: Question about catching exception
Следующее
От: c k
Дата:
Сообщение: Re: plpyhton