salix/db/routines/vn/triggers/collectionVolumetry_afterDe...

27 lines
1.0 KiB
MySQL
Raw Permalink Normal View History

DELIMITER $$
2024-08-20 08:06:10 +00:00
CREATE OR REPLACE DEFINER=`vn`@`localhost` TRIGGER `vn`.`collectionVolumetry_afterDelete`
AFTER DELETE ON `collectionVolumetry`
FOR EACH ROW
BEGIN
DECLARE vJSON JSON DEFAULT JSON_OBJECT();
DECLARE vUserFk INT DEFAULT account.myUser_getId();
SET vJSON = JSON_MERGE(JSON_OBJECT('id', OLD.id), vJSON);
SET vJSON = JSON_MERGE(JSON_OBJECT('level', OLD.level), vJSON);
SET vJSON = JSON_MERGE(JSON_OBJECT('lines', OLD.lines), vJSON);
SET vJSON = JSON_MERGE(JSON_OBJECT('liters', OLD.liters), vJSON);
SET vJSON = JSON_MERGE(JSON_OBJECT('height', OLD.height), vJSON);
SET vJSON = JSON_MERGE(JSON_OBJECT('itemPackingTypeFk', OLD.itemPackingTypeFk), vJSON);
SET vJSON = JSON_MERGE(JSON_OBJECT('trainFk', OLD.trainFk), vJSON);
SET vJSON = JSON_MERGE(JSON_OBJECT('userFk', vUserFk), vJSON);
SET vJSON = JSON_MERGE(JSON_OBJECT('action', 'delete'), vJSON);
SET vJSON = util.notification_send(
'modified-collection-volumetry',
JSON_OBJECT('data', JSON_EXTRACT(vJSON, '$')),
vUserFk
);
END$$
DELIMITER ;