Re: Trigger howto

From: Zbigniew Sliwa <zibi_at_at_yahoo.com>
Date: 2000/09/20
Message-ID: <39C887FE.D3422EAF_at_yahoo.com>#1/1


Greg,

You can assign a value to new column only in the before row triggers. Assuming that start_date and exec_days can't be nulls:

create or replace
trigger my_trigger
before update or insert
on my_table
for each row
begin
  if inserting or updating then

     :new.EXEC_DATE := :new.START_DATE + :new.EXEC_DAYS;   end if;
end;

-- 
Regards,

Zbigniew Sliwa
Oracle Programmer
Poland
email: zibi_at_at_yahoo.com

Greg wrote:

>
> I have a Table like
>
> START_DATE EXEC_DAYS EXEC_DATE
> 15-OCT-00 -10 5-OCT-00
>
> Now I need a Trigger to update
> the EXEC_DATE when the START_DATE changes.
>
> I tried
>
> create or replace
> trigger my_trigger
> after update or insert
> on my_table
> for each row
> begin
> if updating then
> :new.EXEC_DATE := START_DATE + EXEC_DAYS;
> end if;
> end;
>
> But can't use START_DATE and EXEC_DAYS
>
> tried my_table.START_DATE also not worked
>
> do I have to make a select for the START_DATE and EXEC_DAYS
> but how to find the right row...
>
> Found info's about updating other Tables but nothing
> about my problem.
>
> Thanks for any help
> Greg
Received on Wed Sep 20 2000 - 00:00:00 CEST

Original text of this message