Oracle FAQ | Your Portal to the Oracle Knowledge Grid |
Home -> Community -> Usenet -> c.d.o.tools -> Re: How to 'customize' error message from check constraints
gehart25 wrote:
>
>
> Hello,
>
> I am wondering if there is a way to change the
> default error message when a check constraint is
> violated. For example:
>
> 'fsql> insert into test values('0');
> ORA-02290: check constraint (GEORGE.SYS_C001235)
> violated'
>
> How can I change this to:
>
> ORA-02290: The column 'price' must be greater than
> 0.
>
> This would be very benifical to the clients who
> insert data so they know what they did wrong.
>
> Thank you,
> George Hart
> San Diego
>
>
> Sent via Deja.com
> http://www.deja.com/
try somethin like this:
DECLARE
e_products_invalid EXCEPTION;
PRAGMA EXCEPTION_INIT (e_product_invalid, -2292);
v_message Varchar2(40);
BEGIN
...
EXCEPTION
When e_products_invalid THEN
:g_message := 'The column prince must be greater than zero.';
...
END;
/
-- Posted via CNET Help.com http://www.help.com/Received on Tue Feb 06 2001 - 22:30:03 CST