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

Home -> Community -> Usenet -> c.d.o.misc -> Re: Error produced when trigger do raise_application_error

Re: Error produced when trigger do raise_application_error

From: Karsten Farell <kfarrell_at_medimpact.com>
Date: Thu, 10 Oct 2002 23:01:07 GMT
Message-ID: <TEnp9.3234$IG2.171482337@newssvr14.news.prodigy.com>


Lusiana Lusiana wrote:
> Hi All,
>
> I wrote a trigger for enforcing a constraint. The trigger raises an error
> 20001 when some condition is met:
>
> raise_application_error(-20001, 'Unable to delete role ' || :old.role_name
> || ' as it is being referenced by User ' || user.userid);
>
> It behaves as expected, when trigger fires and the condition is met, the
> following error is produced:
>
> ERROR at line 1:
> ORA-20001: Unable to delete role all as it is being referenced by User
> superuser
> ORA-06512: at "MYTEST.ROLE_DELETION", line 29
> ORA-04088: error during execution of trigger MYTEST.ROLE_DELETION'
>
> My question is, why the error ORA-06512 and ORA-04088 are also produced
> along with the raised ORA-20001?
> Is this normal thing that happens when a trigger raise an error?
>
> I have also been having a look at some similar trigger examples on the web,
> and it seems
> that the examples also produce the errors ORA-06512 and ORA-04088.
> I'm using Oracle 8.1.6
>
> Thanks in advance,
>
> Lucy
>
>
>
>

What you need to do is handle the ORA errors on the client side in an EXCEPTION block, where you display the error message passed to RAISE_APPLICATION_ERROR. For example:

DECLARE
   unable_to_delete exception;
   pragma exception_init (unable_to_delete, -20001); BEGIN
   ...
EXCEPTION
   when unable_to_delete then
     dbms_output.put_line(sqlerrm);
END; Received on Thu Oct 10 2002 - 18:01:07 CDT

Original text of this message

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