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: Trigger problem

Re: Trigger problem

From: Michel Cadot <micadot_at_netcourrier.com>
Date: Mon, 24 Sep 2001 13:56:27 +0200
Message-ID: <9on71c$6kq$1@s1.read.news.oleane.net>

"Manfred Priller" <manfred.priller_at_holzbau.com> a écrit dans le message news: 3baf1209$1_1_at_news.telnetwork.it...
> I would like to create a trigger which fire before insert a row in the
> table. In the trigger body i will execute some statements. When this
> statements cause a excption then the line should not be inserted in the
> table.
>
> How can i resolve this problem?
>
>

If your statements generate an exception all the insert statement is automatically rollbacked and the row is not inserted. You can use raise_application_exception in the exception block of your trigger to add your message:

create trigger ... before insert on my_table for each row
begin

   <your statements>
exception

   when others then

      raise_application_exception(-20000,
                                  'insert encountered error '||sqlerrm);
end;
/
--
Have a nice day
Michel
Received on Mon Sep 24 2001 - 06:56:27 CDT

Original text of this message

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