OUTI-Kohan items-taulun triggerit¶
OUTI-Kohan items-taulussa on kaksi triggeriä:
delimiter $$ create trigger before_items_insert before insert on items for each row begin set NEW.permanent_location=NEW.location; end$$ delimiter ;
delimiter $$ create trigger before_items_update before update on items for each row begin set NEW.permanent_location=NEW.location; end$$ delimiter ;
CREATE OR REPLACE DEFINER=`<user>`@`<host>` TRIGGER before_items_insert BEFORE INSERT ON items FOR EACH ROW SET NEW.permanent_location=NEW.location;
CREATE OR REPLACE DEFINER=`<user>`@`<host>` TRIGGER before_items_update BEFORE UPDATE ON items FOR EACH ROW SET NEW.permanent_location=NEW.location;
Triggereillä huolehditaan siitä, että niteen location ja permanent_location tiedot vastaavat aina toisiaan. Huomaa että tämä estää 'CART' -toiminnon (tänään palautetut) käytön!