MySQL 触发器 - 更新后插入不触发插入
MySQL Trigger - After Update Insert Not Triggering Insert
我正在尝试通过使用 MySQL 从初始 table 触发更新后将记录插入日志 table 来记录来自一个 table 的更新。
我似乎无法获得下面的代码来导致插入发生。
我需要做什么来解决这个问题?
触发码
CREATE TRIGGER `issueaim_update` AFTER UPDATE ON `issues`
FOR EACH ROW INSERT INTO issuehistory
SELECT 'update', (select max(revision)+1 from issuehistory where issueid = i.issueid), NOW(), '', IssueID, ProjectID, IssueTitle, Criticality, AssignorID, OwnerID, AltOwnerID, ApproverID, AssignedDate, CompletionDate, DueDate, ECD, ClosedDate, IssueStatement, ClosureCriteria, ClosureStatement, RootCause, CorrectiveAction, IssueResolutionVerification, RejectionJustification, NEW.Category1, Category2, Category3, Category4
FROM ProjectAIM.issues AS i WHERE IssueID = NEW.IssueID and ProjectID = NEW.ProjectID
错误日志 - 最近记录的错误
2016-06-12 21:55:39 10e0 InnoDB: Error: Tablespace for table
"mysql"."innodb_table_stats" is missing.
2016-06-12 21:55:39 10e0 InnoDB: Error: Fetch of persistent statistics
requested for table "projectaim"."issues" but the required system
tables mysql.innodb_table_stats and mysql.innodb_index_stats are not
present or have unexpected structure. Using transient stats instead.
我能够按照下面概述的 4 个步骤解决问题。
1) 首先,我在 phpmyadmin 中备份了 table 作为 sql 导入脚本。
2) 按照下面 解决方案 Link 中的说明,我解决了 table 空间问题。
3) 然后我 运行 sql 再次在 phpmyadmin 中导入脚本/触发器创建脚本来创建,填充 table,然后重新创建我的触发器。
4) 最后,我测试了一个更新,并让它将更新的记录插入到日志中。
解决方案Link -
WAMP Solution for TableSpace Issue
我正在尝试通过使用 MySQL 从初始 table 触发更新后将记录插入日志 table 来记录来自一个 table 的更新。
我似乎无法获得下面的代码来导致插入发生。
我需要做什么来解决这个问题?
触发码
CREATE TRIGGER `issueaim_update` AFTER UPDATE ON `issues`
FOR EACH ROW INSERT INTO issuehistory
SELECT 'update', (select max(revision)+1 from issuehistory where issueid = i.issueid), NOW(), '', IssueID, ProjectID, IssueTitle, Criticality, AssignorID, OwnerID, AltOwnerID, ApproverID, AssignedDate, CompletionDate, DueDate, ECD, ClosedDate, IssueStatement, ClosureCriteria, ClosureStatement, RootCause, CorrectiveAction, IssueResolutionVerification, RejectionJustification, NEW.Category1, Category2, Category3, Category4
FROM ProjectAIM.issues AS i WHERE IssueID = NEW.IssueID and ProjectID = NEW.ProjectID
错误日志 - 最近记录的错误
2016-06-12 21:55:39 10e0 InnoDB: Error: Tablespace for table "mysql"."innodb_table_stats" is missing.
2016-06-12 21:55:39 10e0 InnoDB: Error: Fetch of persistent statistics requested for table "projectaim"."issues" but the required system tables mysql.innodb_table_stats and mysql.innodb_index_stats are not present or have unexpected structure. Using transient stats instead.
我能够按照下面概述的 4 个步骤解决问题。
1) 首先,我在 phpmyadmin 中备份了 table 作为 sql 导入脚本。
2) 按照下面 解决方案 Link 中的说明,我解决了 table 空间问题。
3) 然后我 运行 sql 再次在 phpmyadmin 中导入脚本/触发器创建脚本来创建,填充 table,然后重新创建我的触发器。
4) 最后,我测试了一个更新,并让它将更新的记录插入到日志中。
解决方案Link - WAMP Solution for TableSpace Issue