Re: Help to create a Trigger.

From: Sybrand Bakker <postbus_at_sybrandb.demon.nl>
Date: 2000/07/26
Message-ID: <964622462.5851.3.pluto.d4ee154e_at_news.demon.nl>#1/1


"José Gregório" <jgregorio_at_inforlandia.pt> wrote in message news:397EF587.B3F27F21_at_inforlandia.pt...
>
> Hi!
>
>
> I need to create a trigger.
>
> when an insert, update, delete occurs at a table i should execute the
> same operation on other table, for each row.
>
> How can i build the trigger?
>
>
> Best regards,
>
> GreG.
>
>
>
>

For delete you can use a constraint defined with cascade delete.

For the rest
create or replace trigger redun after insert or update on foo for each row is
begin
if inserting then
 insert into <other table>
values (:new.<column1>,:new.column2,... etc) end if;
if updating then
  update <other table>
 set non_key column1 = :new.nonkey column 1

    , non_key column2 = :new.nonkey.column 2 where key_column = :new.key_column;
end;
/

Could you please refrain from posting to *all* oracle newsgroups, at least one of which is not distributed by my provider. There is really no need to do that. Questions like this one belong in the .server newsgroup.

Regards,

Sybrand Bakker, Oracle DBA Received on Wed Jul 26 2000 - 00:00:00 CEST

Original text of this message