1

Somewhere around here should be a syntax error, but I really can't find one:

DELIMITER |
CREATE TRIGGER Mieter_bi BEFORE INSERT ON Mieter FOR EACH ROW 
BEGIN 
 IF NEW.vorname = '' AND NEW.nachname = '' AND NEW.email = '' AND NEW.mieterID > 0
  THEN DELETE NEW;
 END IF;
END|

Error message:

#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 '; END IF; END|' at line 4

Thanks for helping ;)

1 Answer 1

1

This is how you would cancel an insert

DELIMITER |
CREATE TRIGGER Mieter_bi BEFORE INSERT ON Mieter FOR EACH ROW 
BEGIN 
  IF NEW.vorname = '' AND NEW.nachname = '' AND NEW.email = '' AND NEW.mieterID > 0
  THEN 
    SIGNAL SQLSTATE '45000' SET MESSAGE_TEXT = 'Any Message';
  END IF;
END|
Sign up to request clarification or add additional context in comments.

3 Comments

I still get the same error message at the very same location. Thanks though. The syntax seems to be wrong, but I really can't figure out why...
Still getting this syntax error. #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 '|' at line 7
100% Sure. Anyway, it worked using phpmyadmin and using your code without Delimiter in the trigger tab. Thank you very much ;)

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.