0

I am new to database trigger. I really have no idea why i cant update the Label if the Quantity more than equal to 1000

CREATE TRIGGER TRG_UPDATE_STATUS
AFTER UPDATE ON product
FOR EACH ROW
  BEGIN
    IF NEW.QuantitySold >= 1000 THEN
    SET NEW.Label = 'BestSeller'
    END IF
  END

Here is the trigger I have.

  • Why don't you have any delimiter anywhere? – Tritof Feb 4 '16 at 14:34
2

You can only make persistent changes to NEW in a before row trigger. An after trigger doesn't fire until the record has already been written to the table.

To change the data that will be written to the table, you must use a before row trigger. Changing NEW in an after row trigger is possible, but pointless, since the contents of NEW get written to the table before an after trigger executes, as is explained in the documentation.

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.