Oracle FAQ | Your Portal to the Oracle Knowledge Grid |
![]() |
![]() |
Home -> Community -> Usenet -> c.d.o.misc -> Re: Newbie question on trigger
Both tasks are accomplished via declarative integrity constraints
(FOREIGN KEYs). Oracle automatically enforces them and you
don't need any triggers for this. With proper foreign key constraints
in place Oracle won't allow you to delete a row from parent table
if it has any children (unless your FK is ON DELETE CASCADE or
ON DELETE SET NULL), and it won't allow you to insert a row into
child table if there's no corresponding referenced key in parent, as
well as update it so that it goes out of parent-children relationship
scope. Consult Oracle Concepts manual and SQL Reference for
more information on Referential Integrity Constraints (use this
as search term on http://tahiti.oracle.com if you don't have printed
manuals or docs CD.)
-- Vladimir Zakharychev (bob@dpsp-yes.com) http://www.dpsp-yes.com Dynamic PSP(tm) - the first true RAD toolkit for Oracle-based internet applications. All opinions are mine and do not necessarily go in line with those of my employer. "Andreas Schlegel" <schlegelaw_at_epost.de> wrote in message news:3E351880.8000609_at_epost.de...Received on Mon Jan 27 2003 - 06:00:16 CST
> Hi,
>
> I have a basic question on trigger:
> First I need a procedure that checks if a value exists in an other table
> and if true raise an exception and stop deleting (before delete
> trigger). A second procedure should check if a value exists in an other
> table and if false raise an exception and stop updating or inserting
> (before update/insert trigger).
>
> It's my first pl/sql code so I am not sure if it is better to place the
> code in a trigger or in a procedures.
>
> Does anyone have an example code needed for this case?
>
> Greetings,
> Andreas
>
![]() |
![]() |