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

Home -> Community -> Usenet -> c.d.o.tools -> Re: Delete trigger

Re: Delete trigger

From: Jonathan Gennick <jonathan_at_gennick.com>
Date: 2000/07/12
Message-ID: <ilsoms8fn8gvvle088hhb5no3v6a50jfs8@4ax.com>#1/1

You could look at the raise_application_error function. It will allow you to abort a delete and pass back a custom error message. I've used it for that purpose myself. Here's an example (forgive any syntax errors):

create or replace trigger nodelete
before delete on yourtable
for each row
begin

   --Test some condition
   if :old.emp_first_name = 'Joe'

      raise_application_error (-20000, 'Never delete Joe!');    end if;
end;
/

The :old notation is used to refer to fields in the record that you are deleting. The raise_application_error message takes two arguments: an error number and a message. Both get returned when the error is raised. Error numbers used with raise_application_error should be in the range -20000 to -20999.

Jonathan



jonathan_at_gennick.com
http://gennick.com
Brighten the Corner Where You Are

On Wed, 12 Jul 2000 15:02:52 +0200, "Yann Cauchard" <yann.cauchard_at_spcconsultants.com> wrote:

>I have to avoid deleting lines in a table using a trigger.
>I started to write a before delete trigger, which returns some error
>messages.
>But i'd like to return no messages, or a custom message.
>Can someone help ?
Received on Wed Jul 12 2000 - 00:00:00 CDT

Original text of this message

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