Oracle FAQ | Your Portal to the Oracle Knowledge Grid |
Home -> Community -> Usenet -> c.d.o.tools -> Re: Delete trigger
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
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