Re: Catching Constraint Violations in PL/SQL

From: Martin Bach <martin_bach_at_t-online.de>
Date: 17 Mar 2003 07:17:26 -0800
Message-ID: <d1bc17cb.0303170717.45b4fa50_at_posting.google.com>


postbus_at_sybrandb.demon.nl (Sybrand Bakker) wrote in message news:<a20d28ee.0303130650.77b8f9ee_at_posting.google.com>...
> martin_bach_at_t-online.de (Martin Bach) wrote in message news:<d1bc17cb.0303130242.4274e8a2_at_posting.google.com>...
> > Hi there!
> >
> > Is there a standard way to catch a constraint violation on PL/SQL?
> > I've got something like this:
> >
> > declare
> > ...
> > begin
> > constraint_violation( a,b,c);
> >
> > exception
> > when others then
> > ...
> > end;
> >
> > In the docs, I found a few predefined exceptions (like ZERO_DIVIDE),
> > but no CONSTRAINT_VIOLATED or something similar. DBMS_STANDARD does
> > not define this either, and "PRAGMA EXCEPTION_INIT()" is for user
> > defined exceptions only. So which way is there to catch a constraint
> > violation?
> >
> > TIA,
> >
> > Martin Bach
>
>
> Pragma exception_init is *NOT* for user_exceptions *ONLY*.
> It is quite easy to bind an user-defined name to an Oracle error number
> You don't mention dup_val_on_index for ora-0001 which you could also readily

Of course! I somehow must have overlooked it when skimming the documentation. This was exactly what I was looking for - thanks for the info.

Regards,
Martin Bach Received on Mon Mar 17 2003 - 16:17:26 CET

Original text of this message