我试图使用mysql存储功能。 功能:
DELIMITER $$
CREATE FUNCTION ChangeHistory(newValue VARCHAR(255), oldValue VARCHAR(255), attributeName VARCHAR(255), action VARCHAR(255), entityId BIGINT(20), modifiedBy BIGINT(20)) RETURNS TINYINT(1)
NOT DETERMINISTIC
BEGIN
IF newValue != oldValue THEN
INSERT INTO ChangeHistoryPlayer
SET
action = action,
timeCreated = now(),
entityId = entityId,
modifiedBy= modifiedBy,
attributeName = attributeName,
oldValue = oldValue2,
newValue = newValue2;
END IF;
RETURN 1;
END
触发器中的函数调用:
USE `XXX_admin`;
DELIMITER $$
CREATE TRIGGER `player_AUPD` AFTER UPDATE ON `player` FOR EACH ROW
BEGIN
ChangeHistory(NEW.firstName, OLD.firstName, 'firstName', 'AFTER_UPDATE', NEW.entityId, NEW.modifiedBy);
END
错误(在changeHistoy之后和之前的“(”):
syntax error, unexpected '(' expecting ':'
为什么?
答案 0 :(得分:0)
CREATE TRIGGER `player_aupd` after UPDATE
ON `player`
FOR EACH row
begin
SELECT Changehistory(new.firstname, old.firstname, 'firstName', 'AFTER_UPDATE'
,
new.entityid, new.modifiedby);
end
添加一个选择应该可以做到!
希望这有帮助!