2024-01-15 11:31:03 +00:00
|
|
|
DELIMITER $$
|
2024-08-20 08:06:10 +00:00
|
|
|
CREATE OR REPLACE DEFINER=`vn`@`localhost` TRIGGER `vn`.`travelThermograph_beforeInsert`
|
2024-01-15 11:31:03 +00:00
|
|
|
BEFORE INSERT ON `travelThermograph`
|
|
|
|
FOR EACH ROW
|
|
|
|
BEGIN
|
|
|
|
SET NEW.editorFk = account.myUser_getId();
|
2024-09-26 13:22:40 +00:00
|
|
|
|
|
|
|
IF NEW.travelFk IS NULL AND
|
|
|
|
(SELECT COUNT(*) FROM travelThermograph
|
|
|
|
WHERE thermographFk = NEW.thermographFk
|
|
|
|
AND travelFk IS NULL
|
|
|
|
AND id <> NEW.id) > 0
|
|
|
|
THEN
|
|
|
|
CALL util.throw('Duplicate thermographFk without travelFk not allowed.');
|
|
|
|
END IF;
|
2024-01-15 11:31:03 +00:00
|
|
|
END$$
|
|
|
|
DELIMITER ;
|