Informing end-user of check constraint rules

From: <btober(at)seaworthysys(dot)com>
To: <pgsql-sql(at)postgresql(dot)org>
Subject: Informing end-user of check constraint rules
Date: 2003-06-22 12:45:22
Message-ID: 64845.66.212.203.144.1056285922.squirrel@$HOSTNAME
Views: Raw Message | Whole Thread | Download mbox | Resend email
Thread:
Lists: pgsql-sql

I have not used column check constraints before, but I'd like to start
using then and so would I'll like to know if there is a direct way to
provide feedback to the end user about data validation rules expressed in
column check constraints?

For instance, say that I wanted to use a RE to check e-mail address
format validity and then the data entry clerk typed in invalid data. My
understanding is that when the check constraint returns FALSE, the row
will not insert, and an ExecAppend: rejected due to CHECK constraint
"table_column " exception is raised. That at least tells the column
(albeit in language that would scare the computer-phobe), but I like the
exception message to tell the end user what the format is supposed to be.
Is my only option to have the end-user application (as opposed to the
database) inform the end-user what the correct data format is? If THAT is
so, then it seems I might as well also perform the data formatting
validation in the application, too, so that at least they'ld both be in
the same place and not two separate places.

What I'd like is to be able to specify some kind of error message telling
the user what the correct format should be, and since the proper format
is specified in the database, i.e., in the check constraint, it seems
that the proper place to raise an exception providing the remedial
instructions would also be in the database.

~Berend Tober

Responses

Browse pgsql-sql by date

  From Date Subject
Next Message Germán Gutiérrez 2003-06-22 18:33:06 Re: Delete duplicates
Previous Message Bruno Wolff III 2003-06-22 11:35:59 Re: date question