test_cases テーブル、スケジュール テーブル、aggregate_summary テーブルの 3 つのテーブルがあります。
テストケース
caseID | file_name
--------+-------------------------
1 | Test 1
2 | Test 2
3 | Test 3
スケジュール
| scheduleID | caseID | schedule_time
+------------+--------+---------------------
| 1 | 1 | 2016-02-29 02:15:00
| 2 | 2 | 2016-02-29 12:00:00
| 3 | 3 | 2016-02-27 12:00:00
| 4 | 2 | 2016-02-25 07:26:00
| 5 | 1 | 2016-02-26 07:37:00
| 6 | 2 | 2016-02-27 07:39:00
| 7 | 2 | 2016-02-28 07:25:00
| 8 | 1 | 2016-02-29 08:38:00
| 9 | 2 | 2016-02-29 07:08:00
start_time、ファイル名、その他のフィールドを持つaggregate_summary
トリガーを作成したいので、テストがスケジュールされた後、(aggregate_summary テーブルの) start_time に schedule_time を入れ、aggregate_summary テーブルの file_name フィールドに (test_cases から) file_name を入れます。
構文を正しく取得できません:
CREATE TRIGGER OnScheduleInsert AFTER INSERT ON schedule FOR EACH ROW BEGIN INSERT INTO aggregate_summary (start_time) VALUES(NEW.schedule_time)
UPDATE aggregate_summary SET file_name=(SELECT file_name FROM test_cases WHERE NEW.caseID=test_cases.caseID) END;