From 9b2c0f1c487c957febd5fbcb9990f265c08d7a23 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Carlos=20Andr=C3=A9s?= Date: Thu, 6 Feb 2025 11:46:39 +0100 Subject: [PATCH] feat: refs #8535 log table mandate --- db/routines/vn/triggers/mandate_beforeInsert.sql | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/db/routines/vn/triggers/mandate_beforeInsert.sql b/db/routines/vn/triggers/mandate_beforeInsert.sql index 6fe26604a..090133eef 100644 --- a/db/routines/vn/triggers/mandate_beforeInsert.sql +++ b/db/routines/vn/triggers/mandate_beforeInsert.sql @@ -3,12 +3,12 @@ CREATE OR REPLACE DEFINER=`vn`@`localhost` TRIGGER `vn`.`mandate_beforeInsert` BEFORE INSERT ON `mandate` FOR EACH ROW BEGIN + SET NEW.editorFk = account.myUser_getId(); + IF (NEW.code IS NULL) THEN SET NEW.code=CONCAT(NEW.clientFk,'-',(SELECT AUTO_INCREMENT FROM information_schema.TABLES WHERE TABLE_SCHEMA='vn' and TABLE_NAME='mandate')); END IF; - - SET NEW.editorFk = account.myUser_getId(); END$$ DELIMITER ;