Re: Problem with triggers

Поиск
Список
Период
Сортировка
От Tom Lane
Тема Re: Problem with triggers
Дата
Msg-id 24930.1276658060@sss.pgh.pa.us
обсуждение исходный текст
Ответ на Re: Problem with triggers  (Adrian Klaver <adrian.klaver@gmail.com>)
Ответы Re: Problem with triggers  (Sid <sid.the.technician@gmail.com>)
Список pgsql-general
Adrian Klaver <adrian.klaver@gmail.com> writes:
> On 06/15/2010 02:01 PM, Sid wrote:
>> I am writing trigger function for validating values inserted into table. The
>> goal is to print user friendly messages when inserted value is wrong.

>> My question is: why do I get information about too long value before trigger
>> fires?

> The database is beating you to the validation.

People try this every few months :-(, but it's basically a dead-end idea.
A large majority of the things you might want to report an error for are
going to be rejected by the datatype input functions for the column
datatypes --- for example, you're not going to be able to "print a user
friendly message" on a bad timestamp, because that will be noticed long
before any trigger gets to fire.

You can either decide that the built-in error messages aren't so awful
after all, or do your data validation on the client side.

Or I guess you could lobotomize the database completely by making all
your fields be unlimited-length varchar so that there's no interesting
checking to be done.  But you really, really don't want to go there.

            regards, tom lane

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

Предыдущее
От: Adrian Klaver
Дата:
Сообщение: Re: Problem with triggers
Следующее
От: Jayadevan M
Дата:
Сообщение: Re: Does enterprisedb.com down?