sqlmysqldatabasetriggersmysql-error

I have error "#1363 - There is no NEW row in on DELETE trigger "


I have book and store_order tables.

I want to make trigger(but it contain error):

DELIMITER $$
    
CREATE TRIGGER t1 
BEFORE DELETE ON store_order
FOR EACH ROW 
BEGIN
    
    UPDATE book SET number = number + NEW.quantity WHERE ISBN = NEW.ISBN;
    
END
$$
    
DELIMITER ;

Solution

  • DELIMITER $$
    CREATE
        TRIGGER t2 AFTER delete 
        ON library.store_order
        FOR EACH ROW BEGIN
    
            update library.book 
            set library.book.number = (library.book.number + OLD.quantity)
            where library.book.ISBN = OLD.ISBN;
    
        END$$
    DELIMITER ;