Oracle FAQ | Your Portal to the Oracle Knowledge Grid |
Home -> Community -> Usenet -> c.d.o.server -> Re: Raising an Exception when a Constraint is Violated
Hi Aaron,
You could do the following.
e_constraint_violated EXCEPTION;
2. Associate the above exception to the Oracle error you want trapped also in the declare section:
PRAGMA EXCEPTION_INIT (e_constraint_violated, -2291);
3. Handle the above exception when raised
WHEN e_constraint_violated THEN blah
Good luck
Richard
"Aaron Jaque" <aaron.jaque_at_cybersurf.net> wrote in message
news:3d0f7588$1_1_at_news.cybersurf.net...
> I'm trying to raise an exception when an integrity constraint is violated.
I
> can catch the error with the "WHEN OTHERS" exception, but I want to catch
> the specific error individually. The error looks like this:
> ERROR at line 1:
> ORA-02291: integrity constraint (SCHEMA_NAME.CONSTRAINT_NAME) violated -
> parent key not found
> ORA-06512: at "SCHEMA_NAME.PACKAGE_NAME", line 82
> ORA-06512: at line 1
>
> Is there a way to catch this specific error, maybe by number?
>
> Thanks,
> Aaron
>
>
Received on Tue Jun 18 2002 - 22:58:53 CDT