MySQL Forums
Forum List  »  Triggers

Re: Help for newbie to triggers
Posted by: Greg Johll
Date: September 27, 2005 07:55PM

Correct you are, and many thanks.

The final trigger looks like this:

CREATE TRIGGER updateGroups AFTER UPDATE ON tblPerson
FOR EACH ROW
BEGIN
IF NEW.deletedFlag = 1 THEN
DELETE FROM tblpersongroup WHERE personID=NEW.personID;
ELSEIF NEW.deletedFlag = 0 THEN
INSERT INTO tblpersongroup(personID,groupID) VALUES(NEW.personID,2);
END IF;
END;

(There was a typo in the original, tblPerson.deletedFlag == 2, should have been == 0)

Greg

Options: ReplyQuote


Subject
Views
Written By
Posted
3234
September 26, 2005 08:44PM
2191
September 26, 2005 08:49PM
2285
September 27, 2005 06:08PM
1883
September 27, 2005 06:33PM
Re: Help for newbie to triggers
2198
September 27, 2005 07:55PM


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.