1.
CREATE DEFINER = CURRENT_USER TRIGGER `w`.`groups_BEFORE_DELETE` BEFORE DELETE ON `groups` FOR EACH ROW
BEGIN
   DELETE FROM group_lecturer WHERE OLD.id=group_id;
END
2.
CREATE DEFINER=`studijos`@`%` TRIGGER `students_BEFORE_UPDATE` BEFORE UPDATE ON `students` FOR EACH ROW BEGIN
  IF (NEW.grade>10 OR NEW.grade<1) THEN
    SIGNAL SQLSTATE '45000' SET MESSAGE_TEXT = 'Įvestas pažimys neteisingas';
   
  END IF;
END
3.
CREATE DEFINER=`studijos`@`%` TRIGGER `students_BEFORE_UPDATE` BEFORE UPDATE ON `students` FOR EACH ROW BEGIN
  SET NEW.grant= (SELECT amount FROM `grants` WHERE grade=NEW.grade);
END

Paskutinį kartą modifikuota: Ketvirtadienis, 2022 sausio 13, 18:37