salix/db/routines/hedera/triggers/orderRow_beforeInsert.sql

18 lines
392 B
MySQL
Raw Permalink Normal View History

DELIMITER $$
CREATE OR REPLACE DEFINER=`root`@`localhost` TRIGGER `hedera`.`orderRow_beforeInsert`
BEFORE INSERT ON `orderRow`
FOR EACH ROW
BEGIN
DECLARE vIsFirst BOOL;
SELECT (first_row_stamp IS NULL) INTO vIsFirst
FROM `order`
WHERE id = NEW.orderFk;
IF vIsFirst THEN
UPDATE `order` SET first_row_stamp = util.VN_NOW()
WHERE id = NEW.orderFk;
END IF;
END$$
DELIMITER ;