user7082235
user7082235

Reputation:

Trigger in jdbc

delimiter //
CREATE TRIGGER upd_check BEFORE UPDATE ON Recording
     FOR EACH ROW
     BEGIN
       IF NEW.Format != "WAV" or NEW.Format !="mp3"
            SET NEW.Format = "N/A";
        END IF;
     END//

I am getting an error at line 5, I'm trying to run a trigger so that it will not allow any other format to be accepted than mp3 or wav

Upvotes: 0

Views: 643

Answers (1)

Youcef LAIDANI
Youcef LAIDANI

Reputation: 59986

You are missing THEN keyword in the end of your condition, check the documentation about triggers, and like Jorge Campos mention use single quotes for values as it is SQL ANSI default

FOR EACH ROW 
BEGIN
  IF (LOWER(NEW.Format) != 'wav' OR LOWER(NEW.Format) != 'mp3') THEN 
    BEGIN
      SET NEW.Format = "N/A";
    END; 
  END IF;
END$$

Upvotes: 2

Related Questions