DROP TRIGGER IF EXISTS `InsUser`
DELIMITER $$
CREATE TRIGGER InsUser BEFORE INSERT ON user
FOR EACH ROW
BEGIN
DECLARE isFound INT DEFAULT 0;
SELECT count(*) INTO isFound FROM user WHERE name = NEW.name;
IF isFound == 0 THEN
INSERT INTO user (name, mc_id, lastlogin_date, lastlogin_time) VALUES ( NEW.name, NEW.mc_id, CURDATE(), CURTIME());
ELSE
UPDATE user SET lastlogin_date = CURDATE(), lastlogin_time = CURTIME() WHERE name = NEW.name;
ENDIF;
END;
$$
DELIMITER ;
Meldung:
#1064 - You have an error in your SQL syntax; check the manual that corresponds to your MySQL server version for the right syntax to use near '== 0 THEN INSERT INTO user (name, mc_id, lastlogin_date, lastlogin_time) V' at line 9
warum ist das so ?
mfg LT
DELIMITER $$
CREATE TRIGGER InsUser BEFORE INSERT ON user
FOR EACH ROW
BEGIN
DECLARE isFound INT DEFAULT 0;
SELECT count(*) INTO isFound FROM user WHERE name = NEW.name;
IF isFound == 0 THEN
INSERT INTO user (name, mc_id, lastlogin_date, lastlogin_time) VALUES ( NEW.name, NEW.mc_id, CURDATE(), CURTIME());
ELSE
UPDATE user SET lastlogin_date = CURDATE(), lastlogin_time = CURTIME() WHERE name = NEW.name;
ENDIF;
END;
$$
DELIMITER ;
Meldung:
#1064 - You have an error in your SQL syntax; check the manual that corresponds to your MySQL server version for the right syntax to use near '== 0 THEN INSERT INTO user (name, mc_id, lastlogin_date, lastlogin_time) V' at line 9
warum ist das so ?
mfg LT