Skip to content
Advertisement

I have error “#1363 – There is no NEW row in on DELETE trigger “

I have table “book” and “store_order” have relation

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 ;

Advertisement

Answer

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 ;
User contributions licensed under: CC BY-SA
7 People found this is helpful
Advertisement