Informing end-user of check constraint rules - Mailing list pgsql-sql

From
Subject Informing end-user of check constraint rules
Date
Msg-id 64845.66.212.203.144.1056285922.squirrel@$HOSTNAME
Whole thread Raw
Responses Re: Informing end-user of check constraint rules
List 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





pgsql-sql by date:

Previous
From: Bruno Wolff III
Date:
Subject: Re: date question
Next
From: Germán Gutiérrez
Date:
Subject: Re: Delete duplicates