MySQL Forums
Forum List  »  Triggers

Re: Help for newbie to triggers
Posted by: Jay Pipes
Date: September 26, 2005 08:49PM

You're close! Use the NEW modifier to access the updated information for the tblPerson row.

Delimiter //

CREATE TRIGGER updateGroups AFTER UPDATE ON tblPerson
FOR EACH ROW BEGIN
if (NEW.deletedFlag == 1) {
DELETE FROM tblPersonGroup
WHERE personID = NEW.personID
}

if (NEW.deletedFlag == 2) {
INSERT INTO tblPersonGroup(personID,groupID)
VALUES(NEW.personID,2)
}
END
//

See here for more information:

http://dev.mysql.com/doc/mysql/en/create-trigger.html

Jay Pipes
Community Relations Manager, North America, MySQL Inc.

Got Cluster? http://www.mysql.com/cluster
Personal: http://jpipes.com

Options: ReplyQuote


Subject
Views
Written By
Posted
2919
September 26, 2005 08:44PM
Re: Help for newbie to triggers
2020
September 26, 2005 08:49PM
2115
September 27, 2005 06:08PM
1693
September 27, 2005 06:33PM
2017
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.