MySQL Forums
Forum List  »  Triggers

Re: Query browser does not support trigger edits?
Posted by: Scott Shen
Date: December 06, 2005 09:30AM

Try putting your trigger in *.sql script and QB does support Open/Save *.sql scripts on you file system. So every time you want to update the trigger, just load it into QB, update it and click on Execute. It works quite well for me. Of course you have to have DROP TRIGGER in the begining of your .sql script. Hope this approach suits your need. The folowing is one of the triggers that I installed on our MySQL 5.0.

***********************************************

DELIMITER $$

DROP TRIGGER bugs.bugs_deadline_update$$
CREATE TRIGGER bugs_deadline_update
BEFORE UPDATE
ON bugs
FOR EACH ROW
BEGIN
IF NEW.priority != OLD.priority THEN
CASE
WHEN NEW.priority = 'Current Date + 1 Day' THEN
SET NEW.deadline = ADDDATE(CURDATE(), 1);
SET NEW.bug_file_loc = DATE_FORMAT(NEW.deadline, '%Y-%m-%d');
WHEN NEW.priority = 'Current Date + 2 Days' THEN
SET NEW.deadline = ADDDATE(CURDATE(), 2);
SET NEW.bug_file_loc = DATE_FORMAT(NEW.deadline, '%Y-%m-%d');
WHEN NEW.priority = 'Current Date + 3 Days' THEN
SET NEW.deadline = ADDDATE(CURDATE(), 3);
SET NEW.bug_file_loc = DATE_FORMAT(NEW.deadline, '%Y-%m-%d');
WHEN NEW.priority = 'Current Date + 4 Days' THEN
SET NEW.deadline = ADDDATE(CURDATE(), 4);
SET NEW.bug_file_loc = DATE_FORMAT(NEW.deadline, '%Y-%m-%d');
WHEN NEW.priority = 'Current Date + 5 Days' THEN
SET NEW.deadline = ADDDATE(CURDATE(), 5);
SET NEW.bug_file_loc = DATE_FORMAT(NEW.deadline, '%Y-%m-%d');
WHEN NEW.priority = 'Current Date + 6 Days' THEN
SET NEW.deadline = ADDDATE(CURDATE(), 6);
SET NEW.bug_file_loc = DATE_FORMAT(NEW.deadline, '%Y-%m-%d');
ELSE
SET NEW.deadline = null;
SET NEW.bug_file_loc = '';
END CASE;
END IF;
END;$$

DELIMITER ;

Options: ReplyQuote


Subject
Views
Written By
Posted
Re: Query browser does not support trigger edits?
5195
December 06, 2005 09:30AM


Sorry, you can't reply to this topic. It has been closed.

Content reproduced on this site is the property of the respective copyright holders. It is not reviewed in advance by Oracle and does not necessarily represent the opinion of Oracle or any other party.