Oracle FAQ | Your Portal to the Oracle Knowledge Grid |
Home -> Community -> Usenet -> c.d.o.server -> Re: trigger statement:
spliffmonkey_at_iname.com wrote:
> Quick question. This trigger works fine (it just sets a themepark rides
> status as closed when an accident has been inserted into the accident
> table):
>
> CREATE TRIGGER closeride
> AFTER INSERT ON Accident
> REFERENCING NEW AS newRow
> FOR EACH ROW
> BEGIN
> update Ride set Ride.status = 'closed' where Ride.Ridename =
> :newRow.Ridename;
> END closeride;
>
> Now I want to make a variation on this where if the accident table
> returns more than 3 rows for a given ride then the ride status is set
> to closed. This is my attempt (bellow). Could someone take a look at
> it? Its the same as the one above except for the WHEN
>
> CREATE TRIGGER toomanyaccidents
> AFTER INSERT ON Accident
> REFERENCING NEW AS newRow
> FOR EACH ROW
> WHEN((select * from accident where Ridename = :new.Ridename)> 2)
> BEGIN
> update Ride set Ride.status = 'closed' where Ride.Ridename =
> :newRow.Ridename;
> END closeride;