Skip to content
Advertisement

Trigger created with compilation errors

I wrote this trigger to discount the top client in the database by 10% when a new purchase is made:

However when i execute this statement i receive this message:

Can someone please tell me what I am doing wrong?

Thanks, Alex.

UPDATE – Errors:

Solution:

Advertisement

Answer

I don’t have your tables to hand so I can’t guarantee that I’ve found all your errors. However, I can say the following:

  1. I don’t believe you can do SELECT (....).CLIENTNO. Try SELECT x.CLIENTNO FROM (....) x instead.
  2. Your outermost SELECT doesn’t have a FROM clause. Try adding FROM DUAL, since this outermost SELECT isn’t selecting from any tables.
  3. The PL/SQL assignment operator is :=, not =. To assign to :NEW.AMOUNT, you need to write :NEW.AMOUNT := (:NEW.AMOUNT * 0.1);.
  4. Multiplying the amount by 0.1 gives the client a 90% discount, not a 10% discount.
User contributions licensed under: CC BY-SA
9 People found this is helpful
Advertisement