Oracle FAQ | Your Portal to the Oracle Knowledge Grid |
![]() |
![]() |
Home -> Community -> Usenet -> c.d.o.server -> Re: simple trigger - beginner need help
This seems to work...
create or replace trigger tr_update
BEFORE update of colA on my_table
for each row
BEGIN
:NEW.colB := 'TESTTRIGGER';
END;
Robert Prendin
daud11_at_hotmail.com wrote:
>Hi
>
>I am trying to create a trigger to automatically update column B after column
>A has been updated. For example, let say my table my-table has 2 cols colA
>and colB. I want whenever ColA is updated, colB get updated automatically but
>I am not sure how to write the trigger to do just that. I have tried using
>the code below but it still won't work.
>
>create trigger tr_update
>after update of colA on my-table
>for each row
>BEGIN
> update my-table set colB = <some calculation>
> where colA = :new.ColA;
>END;
>
>I tried something like the above and I got an error saying table is mutating
>etc etc. I hope somebody can help me and I would also appreciate if a copy
>can be send to my hotmail address at daud11_at_hotmail.com
>
>thank you
>Daud11
>
>-----------== Posted via Deja News, The Discussion Network ==----------
>http://www.dejanews.com/ Search, Read, Discuss, or Start Your Own
Robert Prendin
RP Data Solutions Inc.
Specializing in ORACLE DBA Support Services
Received on Sat Jan 23 1999 - 08:25:32 CST
![]() |
![]() |