Own messages for constraints?

From: "Kacper Chrapa" <k(dot)chrapa(at)wp(dot)pl>
To: pgsql-general(at)postgresql(dot)org
Subject: Own messages for constraints?
Date: 2007-03-16 19:19:41
Message-ID: 45faedcd4721c@wp.pl
Views: Raw Message | Whole Thread | Download mbox | Resend email
Thread:
Lists: pgsql-general

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 case) than "violates constraint
zip_code_check" :-) .

I can make this validation in trigger (and send msg to application by
notice or raise),but in this case i will duplicate validation
rules (in trigger and in constraint).Effect: Lower performance(i think)
and rules in two places...

Best regards and thanks for help,
Kacper Chrapa

----------------------------------------------------
Fantastyczna promocja w RUCHu! Rób zakupy, wysyłaj SMSy
i codziennie wygrywaj bony pieniężne!
W finale do wygrania Nissan NOTE.
Sprawdź: http://klik.wp.pl/?adr=www.loteriaruch.pl&sid=1062

Responses

Browse pgsql-general by date

  From Date Subject
Next Message Erik Jones 2007-03-16 19:22:04 Re: PostgreSQL 8.2.3 VACUUM Timings/Performance
Previous Message Joshua D. Drake 2007-03-16 19:17:37 Re: planning issue