From: | Sid <sid(dot)the(dot)technician(at)gmail(dot)com> |
---|---|
To: | pgsql-general(at)postgresql(dot)org |
Subject: | Re: Problem with triggers |
Date: | 2010-06-16 05:17:12 |
Message-ID: | AANLkTina6ud9-WTq5WhtHLp-FVAu925tavvOl9pPZyIf@mail.gmail.com |
Views: | Raw Message | Whole Thread | Download mbox | Resend email |
Thread: | |
Lists: | pgsql-general |
2010/6/16 Tom Lane <tgl(at)sss(dot)pgh(dot)pa(dot)us>
> Adrian Klaver <adrian(dot)klaver(at)gmail(dot)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.
I tried to search for this problem, but I failed :(. I spend few hours
trying to find what is
wrong with my code.....
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.
>
I didn't think about that,
>
> 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.
>
Yes, I'll probably do this that way.
> 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.
>
No. This solution is too ugly even for me :)
>
> regards, tom lane
>
Thank you for your explanation, Tom
--
Best regards
Sid
From | Date | Subject | |
---|---|---|---|
Next Message | Sid | 2010-06-16 05:26:27 | Re: Problem with triggers |
Previous Message | A. Kretschmer | 2010-06-16 05:09:24 | Re: Ideal Disk recommendation for PostgreSQL |