Re: [GENERAL] Own messages for constraints?

2007-03-19 Thread Jeff Davis
On Fri, 2007-03-16 at 20:19 +0100, Kacper Chrapa wrote: Hi ! Is it possible in postgres to define own message for some constraint? Example: If i create check constraint on zip_code column , i want to get a message: Zip code is invalid.Please,input code in format: nn-nnn and I want to

Re: [GENERAL] Own messages for constraints?

2007-03-19 Thread hubert depesz lubaczewski
On 3/19/07, Jeff Davis [EMAIL PROTECTED] wrote: You can use an AFTER trigger instead of a CHECK constraint (but that may have a performance impact - test for your application). are you sure you meant AFTER? why? generally data-checks should be in before triggers. i guess. depesz --

Re: [GENERAL] Own messages for constraints?

2007-03-19 Thread Martijn van Oosterhout
On Mon, Mar 19, 2007 at 07:08:41PM +0100, hubert depesz lubaczewski wrote: On 3/19/07, Jeff Davis [EMAIL PROTECTED] wrote: You can use an AFTER trigger instead of a CHECK constraint (but that may have a performance impact - test for your application). are you sure you meant AFTER? why?

Re: [GENERAL] Own messages for constraints?

2007-03-19 Thread hubert depesz lubaczewski
On 3/19/07, Martijn van Oosterhout kleptog@svana.org wrote: In an AFTER trigger you can be sure you're seeing what actually got inserted. In a BEFORE trigger other triggers after you could still modify the data... yes but in after trigger the only thing you can do is to raise exception. you

Re: [GENERAL] Own messages for constraints?

2007-03-19 Thread Jeff Davis
On Mon, 2007-03-19 at 19:08 +0100, hubert depesz lubaczewski wrote: On 3/19/07, Jeff Davis [EMAIL PROTECTED] wrote: You can use an AFTER trigger instead of a CHECK constraint (but that may have a performance impact - test for your application). are you sure you meant AFTER? why? generally

Re: [GENERAL] Own messages for constraints?

2007-03-19 Thread Jeff Davis
On Mon, 2007-03-19 at 19:26 +0100, hubert depesz lubaczewski wrote: On 3/19/07, Martijn van Oosterhout kleptog@svana.org wrote: In an AFTER trigger you can be sure you're seeing what actually got inserted. In a BEFORE trigger other triggers after you could still modify the data... yes

[GENERAL] Own messages for constraints?

2007-03-18 Thread Kacper Chrapa
Hi ! Is it possible in postgres to define own message for some constraint? Example: If i create check constraint on zip_code column , i want to get a message: Zip code is invalid.Please,input code in format: nn-nnn and I want to send this message to the end user. It will be much better(in my