tonelm54
asked on
Trigger Update not working if starts null
If got a simple trigger which is to update a log table (which I unfortunately need), however if the value of `phoneNumber` is its default of Null, when I update it like:-
My trigger code is:-
Any ideas what Im doing wrong?
UPDATE `contract` SET `phoneNumber` = '44464' WHERE `contract`.`priID` = 8;
I dont get a line in the logger, however if I execute again differently so the so OLD.`phoneNumber` isnt null then trigger fires fine and runs the insert command.My trigger code is:-
Begin
IF OLD.`phoneNumber` <> NEW.`phoneNumber` THEN
INSERT INTO `mobilephones`.`_logger` (`dateTime`, `connectionID`, `table`, `priID`, `feild`, `newValue`,`action`) VALUES (NOW(), CONNECTION_ID(), 'contract', NEW.`priID`, 'phoneNumber', NEW.`phoneNumber`, 'Update');
END IF;
End
Any ideas what Im doing wrong?
ASKER CERTIFIED SOLUTION
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.