views:

186

answers:

2

Hi

I have two tables

Orders(ID,ORDERDATE,DELIVERYDATE,GOODID,QUANTITY,COLLECTIONFROM,DELIVERYTO,NOTES)

and

ROLLINGSTOCK_ORDER(ORDERID,ROLLINGSTOCKID,DEPARTUREDATE,DELIVERYDATE,ROUTEID)

i have created a trigger to update the DELIVERYDATE in ROLLINGSTOCK_ORDER when DELIVERYDATE is updated in Orders

CREATE OR REPLACE TRIGGER TRIGGER_UpdateDeliveryDate
BEFORE UPDATE OF DELIVERYDATE ON Orders 
FOR EACH ROW 
BEGIN    
then
   UPDATE LOCOMOTIVE_DRIVER ld
   set ld.DELIVERYDATE = :new.DELIVERYDATE
   where ld.orderid = :new.id
end if;
END;

When i run it i get the following message

Warning: execution completed with warning TRIGGER TRIGGER_UpdateDeliveryDate Compiled.

The warning does not give me any information so

  1. How can i see the details of the warning?

  2. The trigger seems ok to me can you spot the problem?

Thanks

A: 

You write

BEGIN    
then

which is incorrect syntax. Are you missing an IF?

You are also missing a semicolon (;) after your UPDATE.


You might get the error using

Show Error Trigger TRIGGER_UpdateDeliveryDate
Peter Lang
A: 

Earlier this week you asked a question on writing a trigger to execute a conditional update. I posted two examples of how to achieve that end. What you appear to have done is mash the two examples into a single spavined trigger which doesn't compile.

To be clear you need just one of the following. Either

BEFORE UPDATE OF DELIVERYDATE ON Orders

or

 BEFORE UPDATE ON Orders 
 ... 
    if :new.delivery_date != :old.delivery_date then

Use the first option if you just have the one piece of logic to apply. Use the second version if you want your trigger to handle other pieces of logic as well, which is usually the case.

APC