MySQL Triggers Liquibase



我设置了liquibase。我目前有 4-5 个触发器要加载,每个触发器存储在一个单独的文件中。所有触发器都位于单独的表上。但是我不断收到此错误:

严重 13-9-17 下午12:05:liquibase:更改集迁移/09-16-2013-16-10.sql::129 失败。 错误:执行 SQL 分隔符 $$ 时出错

DELIMITER $$
CREATE TRIGGER `UPDATE_tableA` BEFORE UPDATE on `tableA`
FOR EACH ROW BEGIN
IF (OLD.ColumnA = NEW.ColumnA) and 
  ((OLD.ColumnB is null and NEW.ColumnB is null) or (OLD.ColumnB = NEW.ColumnB)) and 
  ((OLD.ColumnB is null and NEW.ColumnB is null) or (OLD.ColumnB = NEW.ColumnB)) and 
  ((OLD.ColumnC is null and NEW.ColumnC is null) or (OLD.ColumnC = NEW.ColumnC))  
  THEN
    SET NEW.ColumnA = 0;
    SET NEW.ColumnB = NULL;
    SET NEW.ColumnB = NULL;
    SET NEW.ColumnC = NULL;
END IF;
END$$
DELIMITER ;
DELIMITER $$
CREATE TRIGGER `UPDATE_tableB` BEFORE UPDATE on `tableB`
FOR EACH ROW BEGIN
IF (OLD.ColumnA = NEW.ColumnA) and 
  ((OLD.ColumnB is null and NEW.ColumnB is null) or (OLD.ColumnB = NEW.ColumnB)) and 
  ((OLD.ColumnB is null and NEW.ColumnB is null) or (OLD.ColumnB = NEW.ColumnB)) and 
  ((OLD.ColumnC is null and NEW.ColumnC is null) or (OLD.ColumnC = NEW.ColumnC))  
  THEN
    SET NEW.ColumnA = 0;
    SET NEW.ColumnB = NULL;
    SET NEW.ColumnB = NULL;
    SET NEW.ColumnC = NULL;
END IF;
END$$
DELIMITER ;

'endDelimiter' 是一个正则表达式,所以试试这个

<sqlFile endDelimiter="$$" path="..."/>

DELIMITER $$是MySQL客户端解析器理解的命令,但不是通过Liquibase使用的JDBC理解的命令。

您需要在引用文件的方式中指定分隔符,可能<sqlFile endDelimiter="$$" path="..."/>

相关内容

  • 没有找到相关文章

最新更新