Oracle FAQ | Your Portal to the Oracle Knowledge Grid |
![]() |
![]() |
Home -> Community -> Usenet -> c.d.o.misc -> Re: Create a trigger
In article <8ciajf$18m3$1_at_news5.isdnet.net>,
"Georges-Eric DESROUSSEAUX" <georges_at_francenet.fr> wrote:
> Hello,
>
> I need to create two triggers in an Oracle database, but I don't know
> PL/SQL.
>
> I have:
> - a table called "illustration" with 2 columns
('ilu_id', 'ilu_path')
> - a table called "container" with 2 columns ('ctn_id', 'ctn_path')
>
> - a third table "illustration_composition" with 2 columns
('ilu_id',
> 'ctn_id') is used to make the relations between thos two tables.
>
create trigger keep_ctn_in_sync_1
before update of ilu_path on illustration
for each row
begin
if updating then
--this is for update 1
select ctn_id into v_ctn_id from illustration_composition where
ilu_id = :new.ilu_id;
update containser set ctn_path = :new.ilu_path
where ctn_id = v_ctn_id;
end if;
end;
> 1) When The field ilu_path is modified, the field ctn_path must be
updated
> with the same value.
>
> 2) When there is a new association between the tables illustration and
> container,
> field ctn_path must be set with the value of ilu_path.
create trigger keep_ctn_path_in_sync_2
before update on illustration_composition
for each row
begin
ilu_path illustration.ilu_path%type;
if updating then
--this is for update 2
select ilu_path into v_ilu_path from illustration
where ilu_id = :new.ilu_id;
update containser set ctn_path = v_ilu_path where ctn_id = :new.ctn_id;
end if;
end;
>
I have not tried it myself but it should work.
Good luck/Bonne Chance
Cheers
JC
> I think the code of those two triggers are not so difficult, but I
don't
> know at all the PL/SQL.
> Can somebody help me ?
>
> Thanks a lot.
>
>
Sent via Deja.com http://www.deja.com/
Before you buy.
Received on Thu Apr 06 2000 - 11:19:22 CDT
![]() |
![]() |