MySQL Forums
Forum List  »  Triggers

Re: Simple (!) Triggers failing
Posted by: Tony Barnsley
Date: July 13, 2011 07:19AM

Certainly a couple of flaws in my understanding of the required syntax . . plus my usual balls up over NOT and OR logic.

This trigger appears to do what I want

DELIMITER |
CREATE TRIGGER mem_users_BeforeUpdate
BEFORE UPDATE ON mem_users
FOR EACH ROW
BEGIN

SET NEW.Updated = 'N' ;

IF ( ( OLD.f1 != NEW.f1 )
OR ( OLD.f2 != NEW.f2 )
OR ( OLD.f3 != NEW.f3 )
OR ( OLD.f4 != NEW.f4 )
OR ( OLD.f5 != NEW.f5 )
OR ( OLD.f7 != NEW.f7 ) ) THEN SET NEW.updated = 'Y' ;
END IF;

END|
DELIMITER ;

I'm a happy bunny now . . .Until I break it later ;)

Options: ReplyQuote


Subject
Views
Written By
Posted
1718
July 13, 2011 07:05AM
Re: Simple (!) Triggers failing
1011
July 13, 2011 07:19AM


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.