Re: Custom Constraint Violation Errors

Поиск
Список
Период
Сортировка
Искать
От
Richard Broersma
Тема
Re: Custom Constraint Violation Errors
Дата
Msg-id
CABvLTWFCKy2_YRCS17+mQCz7CDkAikheeDYesfOk5KDDvnsfJA@mail.gmail.com
Ответ на
Список
Дерево обсуждения
Custom Contraint Violation Errors "Michael Musenbrock" <redeamer@gmx.net>
Re: Custom Contraint Violation Errors Richard Broersma <richard.broersma@gmail.com>
Re: Custom Constraint Violation Errors Michael Musenbrock <redeamer@gmx.net>
Re: Custom Constraint Violation Errors Richard Broersma <richard.broersma@gmail.com>
Re: Custom Constraint Violation Errors Craig Ringer <ringerc@ringerc.id.au>
On Mon, Nov 7, 2011 at 2:47 PM, Michael Musenbrock  wrote:

> was intentionally looking for a trigger firing on violating of an
> already existing constraint.
>
> So am I got that right, that If I want to have eg custom error messages
> for a foreign
> key violation, I need to replace all fkeys by trigger functions?!

I see.  The short answer is, while it is possible to custom make your
own constraint triggers that emulate foreign keys, don't do it.  This
would be a maintenance nightmare.

I'd be more maintainable to catch these errors in your client
application.  Here you would reword these error messages according the
business rules of your client application.

If you insist that the server rewrite your error messages, then you'll
need to create stored functions that will preform the desired
operations; catch any possible errors; and then throw the altered
error messages.  But remember that catching errors and throwing them
will have a performance penalty.

http://www.postgresql.org/docs/9.1/interactive/plpgsql-control-structures.html#PLPGSQL-ERROR-TRAPPING

-- 
Regards,
Richard Broersma Jr.
В списке pgsql-general по дате отправления
От: John R Pierce
Дата:
Сообщение: Re: Simple question on SELECT
От: Richard Huxton
Дата:
FAQ