Re: Protect record from deletion via trigger
Date: Wed, 2 Jul 2008 06:14:33 -0700 (PDT)
Message-ID: <6c1e28b8-e04c-4480-8058-866814bb9763@z24g2000prf.googlegroups.com>
On Jul 2, 11:37 am, "markus.schre..._at_gmail.com"
<markus.schre..._at_gmail.com> wrote:
> Hi joel,
>
> can you give me some details about this child table idea. I don't get
> it yet.. =) sorry.. :)
>
> Markus
You just create another table and add foreign key constraint to it referencing your table. You then insert single row into the "child" table with the foreign key pointing to the row in the "master" table you want to protect. Now if someone tries to delete that row, Oracle will throw ORA-02292 because a child row exists for it. Note that foreign key constraints require primary or unique key constraint on the master table to be in place. Your app should also be able to handle the error adequately.
Regards,
Vladimir M. Zakharychev
N-Networks, makers of Dynamic PSP(tm)
http://www.dynamicpsp.com
Received on Wed Jul 02 2008 - 08:14:33 CDT