Oracle FAQ Your Portal to the Oracle Knowledge Grid
HOME | ASK QUESTION | ADD INFO | SEARCH | E-MAIL US
 

Home -> Community -> Usenet -> c.d.o.server -> Re: Raising an Exception when a Constraint is Violated

Re: Raising an Exception when a Constraint is Violated

From: MS <qcom_at_attbi.com>
Date: 19 Jun 2002 10:55:00 -0700
Message-ID: <a2b6d46b.0206190955.78193c14@posting.google.com>


Use the variable SQLCODE, which returns the error number (like -2291) or you could use SQLERRM that returns the entire message text.

So in the when others clause:
 if (sqlcode=-2291) then ...<do whatever>  end if;

-Madhu S

"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 Wed Jun 19 2002 - 12:55:00 CDT

Original text of this message

HOME | ASK QUESTION | ADD INFO | SEARCH | E-MAIL US