Oracle FAQ Your Portal to the Oracle Knowledge Grid
HOME | ASK QUESTION | ADD INFO | SEARCH | E-MAIL US
 

Home -> Community -> Usenet -> c.d.o.misc -> Re: Triggers on Oracle7 - newbie

Re: Triggers on Oracle7 - newbie

From: Mark C. Stock <mcstockX_at_Xenquery>
Date: Tue, 22 Mar 2005 06:46:17 -0500
Message-ID: <v8ydnUduq-oTmN3fRVn-jg@comcast.com>

"Keith" <keith.wilby_at_AwayWithYerCrap.com> wrote in message news:Xns9621748696B7Ekeithwilby_at_10.15.188.42...
> "Mark C. Stock" <mcstockX_at_Xenquery .com> wrote:
>
>> first, why version 7? it's way obsolete
>
> I know, but that's what I'm stuck with where I work.
>
>>
>> however, this issue is the same across database versions (starting with
>> 7)
>>
>> you need to create a row-level trigger -- check out the FOR EACH ROW
>> keywords in the SQL Reference manual
>>
>> typical example:
>>
>> create or replace trigger tasks_bir
>> before insert on tasks
>> for each row
>> begin
>> select tasks_id.nextval into :new.id from dual;
>> end;
>
> I did wonder about "FOR EACH ROW" but wouldn't that update all rows?
> Remember I'm a clueless newbie!
>
> Thanks for your help.
> Keith.

The clause causes the trigger to fire for each row that the DML statement affects. You can use the WHEN clause, or logic in your trigger, to determine if a certain row that has been inserted, updated, or deleted should be processed by the trigger. Rows that are not affected the the DML statement are never processed by a row trigger.

This behavior is described in the SQL Reference manual under the CREAT E TRIGGER statement.

++ mcs Received on Tue Mar 22 2005 - 05:46:17 CST

Original text of this message

HOME | ASK QUESTION | ADD INFO | SEARCH | E-MAIL US