Simple (!) Triggers failing
Hello all,
Trying to set up a simple trigger to avoid hacking core php code at the front end.
I have a simple table mem_users with 7 fields in it
(user_id int ( 11 ) ,
updated SET ( 'Y' , 'N' ) DEFAULT 'Y' ,
f1 varchar ( 255) ,
f2 varchar ( 255) ,
f3 varchar ( 255) ,
f4 varchar ( 255) ,
f5 varchar ( 255) ,
f6 varchar ( 255) )
What happens is that I have a script triggered by a web page that looks for any rows with updated = Y, if it finds any it process them (updates the geocaching data) and sets the updated flag to N. What I would like to do is when the user changes the values in the table through their profile is have a trigger set the updated field to Y. . . . Simple enough right? . . . It is in SQL Server (Sorry Paid work got the better of me :) )
DELIMITER |
CREATE TRIGGER mem_users_BeforeUpdate
BEFORE UPDATE ON mem_users
FOR EACH ROW
BEGIN
IF NOT ( ( 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.f6 = NEW.f6 ) ) SET NEW.updated = 'Y' ;
END;
DELIMITER ;
The trigger installs fine through phpMyAdmin, but never gets triggered . . .I've tried changing it through phpMyAdmin via Update Statements, editing the table directly, and using the website front end . . . nothing fires the trigger. In desperation I changed the trigger to check one field and if new and old values are different write them out to a table.
DELIMITER |
CREATE TRIGGER mem_users_BeforeUpdate
BEFORE UPDATE ON mem_usersFOR EACH ROW
BEGIN
INSERT INTO testjr_users (OldValue , NewValue ) VALUES ( OLD.f1 , NEW.f1) ;
END;
DELIMITER ;
Nothing fires the trigger. . . .Really starting to bug me now
Regards
Tony
Subject
Views
Written By
Posted
Simple (!) Triggers failing
2066
July 13, 2011 07:05AM
1214
July 13, 2011 07:19AM
1106
July 14, 2011 08:22AM
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.