DROP PROCEDURE IF EXISTS updateEventAttendeeName;

DELIMITER $$$
CREATE PROCEDURE updateEventAttendeeName(_userId int unsigned, _firstName VARCHAR(255), _lastName VARCHAR(255))
not deterministic modifies sql data
BEGIN
    UPDATE `qs_EventAttendee` SET `firstName` = _firstName, `lastName` = _lastName WHERE `userId` = _userId;
END $$$
DELIMITER ;

DELIMITER $$$
DROP TRIGGER IF EXISTS `User_au` $$$
CREATE TRIGGER `User_au` AFTER UPDATE
ON `qs_User` FOR EACH ROW
begin
    IF NEW.firstName != OLD.firstName OR  NEW.lastName != OLD.lastName  THEN
        CALL updateEventAttendeeName(NEW.id, NEW.firstName, NEW.lastName);
    END IF;
end $$$
DELIMITER ;
