Skip to content

Commit

Permalink
sql: Change trigger syntax for MySQL 5 database
Browse files Browse the repository at this point in the history
The syntax for multiple triggers for the same event and table works for
MySQL 8 databases but is not accepted for MySQL 5 databases.

Refactor the statements from the `mxq_udpate_job2` trigger into the
`mxq_update_job`trigger.
  • Loading branch information
donald committed Dec 29, 2023
1 parent 7bfcc38 commit 48746e8
Showing 1 changed file with 2 additions and 6 deletions.
8 changes: 2 additions & 6 deletions mysql/create_trigger.sql
Original file line number Diff line number Diff line change
Expand Up @@ -134,19 +134,15 @@ CREATE TRIGGER mxq_update_job BEFORE UPDATE ON mxq_job
WHERE group_id = NEW.group_id;
END IF;
END IF;
END;
|

DROP TRIGGER IF EXISTS mxq_update_job2|
CREATE TRIGGER mxq_update_job2 BEFORE UPDATE ON mxq_job
FOR EACH ROW FOLLOWS mxq_update_job
IF NEW.job_status = 0 AND NEW.job_cancelled THEN
SET NEW.job_status = 990; -- CANCELLED
UPDATE mxq_group SET
group_jobs_inq = group_jobs_inq - 1,
group_jobs_cancelled = group_jobs_cancelled + 1
WHERE group_id = NEW.group_id;
END IF;
END;
|

DELIMITER ;
UNLOCK TABLES;

0 comments on commit 48746e8

Please sign in to comment.