I've got problem with combining triggering and if functions. In phpmyadmin's tool Triggers everything's working just fine, but when I paste this code to console, MySQL returns error:
#1064 - You have an error in your SQL syntax; check the manual that corresponds to your MySQL server version for the right syntax to use near '' at line 1
I need to transfer some columns from row from 'Kompozycje' (table with all products) to 'Zapotrzebowanie' (table with needed items) when items in stock (stan) drops below minimal level (minimum). I just can't get this to work in console. Could somebody tell me what's wrong with my code?
CREATE TRIGGER `dodaj_zapotrz` AFTER UPDATE ON `Kompozycje` FOR EACH ROW
IF NEW.stan < NEW.minimum THEN
INSERT INTO `Zapotrzebowanie` (`idkompozycji`, `minimum`, `nazwa`, `stan`)
VALUES (NEW.idkompozycji,NEW.minimum,NEW.nazwa,NEW.stan);
END IF;
And tables look like this:
`Kompozycje` (`idkompozycji`,`nazwa`,`opis`,`cena`,`minimum`,`stan`)
`Zapotrzebowanie` (`idkompozycji`,`nazwa`,`minimum`,`stan`)
Aucun commentaire:
Enregistrer un commentaire