Re: Protect record from deletion via trigger

From: hpuxrac <johnbhurley_at_sbcglobal.net>
Date: Tue, 1 Jul 2008 10:38:58 -0700 (PDT)
Message-ID: <09290744-e181-4c68-b69c-a6ff3972d6c0@26g2000hsk.googlegroups.com>


On Jul 1, 11:20 am, "markus.schre..._at_gmail.com" <markus.schre..._at_gmail.com> wrote:
> Hi all,
>
> I have a question regarding delete triggers. is there a way to protect
> one specific record of a table from deletion? The way to do it with a
> view and instead triggers is not possible. Also i can't raise an
> APPLICATION_ERROR, since the whole thing should not be visible from
> application side. Is there a way to do this?
>
> CREATE OR REPLACE
> TRIGGER
> PROTECT_REC
> BEFORE DELETE ON TARGETTABLE
> FOR EACH ROW
> BEGIN
>   IF (:old.PKCOL=1) THEN
>    Null;
>   END IF;
> END;
>
> Thanks.. :)

Tom Kyte says ( and I believe him ) "Triggers are evil" ... therefore don't use them at all or at least minimize their usage.

Certainly don't try to protect a specific record within a trigger that is just madness!

You could I suppose have a procedure that looks to see if a certain record is there and inserts it/updates it if it has gone away ... execute that on some periodic basis if you must. Received on Tue Jul 01 2008 - 12:38:58 CDT

Original text of this message