Could anyone tell me that what is the syntax error in this trigger
DELIMITER |
CREATE TRIGGER User_XEntity_Before_Delete
BEFORE DELETE
ON UserXEntity FOR EACH ROW
BEGIN
-- Insert record into Delete_UserXEntity table
INSERT INTO Delete_UserXEntity
( DeletedUserXEntityId,
UserId,
CreatedAt)
VALUES
( OLD.Id,
OLD.UserId,
NOW() );
END;
|
DELIMITER ;
I've got the solution. Actually I was entering this code in phpmyadmin
Trigger window, where it asks about table name, time and event already. So we only need to write the trigger action code in that window. I was writing the whole trigger code and that's why I was giving me a syntax error.
We only need to write the following code in PHPMYADMIN
add new trigger windows:
INSERT INTO Delete_UserXEntity
( DeletedUserXEntityId,
UserId,
CreatedAt)
VALUES
( OLD.Id,
OLD.UserId,
NOW() );
The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.