Re: Change default error message on check constraint



On Feb 29, 3:07 am, DA Morgan <damor...@xxxxxxxxx> wrote:
dean wrote:
Hi,

[10g/Win]

Is there a way to change the error message given to a user when a
check constraint is violated?

For example, instead of:

"ORA-02290: Check constraint (GC_JAN08.TR_ORIG_T_BEFORE_DEPT_T)
violated"

I would prefer to see:

"Error: Origination time must be before departure time."

I realize this can always be done in the app code.

Thanks!

Remap it using PRAGMA EXCEPTION_INIT

Go to Morgan's Library atwww.psoug.organd look up this pragma
for a demo.
--
Daniel A. Morgan
Oracle Ace Director & Instructor
University of Washington
damor...@xxxxxxxxxxxxxxxx (replace x with u to respond)
Puget Sound Oracle Users Groupwww.psoug.org- Hide quoted text -

- Show quoted text -

Dean, my personal opinion is that generally it is better to change the
error message in the application code so that when an error occurs you
can capture the real Oracle error code and message behind the scenes
for the developers to use in debugging and problem resolution rather
than override the message via a pragma.

There are cases where for a specific error changing the pragma will
not remove data beneficial to debugging or necessary for problem
resolution and your example seems to be such a case but be careful
that the technique is over used by the developers.

HTH -- Mark D Powell --
.