Sergey Onishchenko
Sergey Onishchenko

Reputation: 7851

MySql on update trigger. Error of DELIMITER

I try to create trigger in MySql but get the following 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 'DELIMITER' at line 1

DELIMITER $$
CREATE TRIGGER library_update
AFTER UPDATE ON wq6vt_vehiclemanager_vehicles
FOR EACH ROW 
BEGIN
    INSERT IGNORE INTO wq6vt_vehiclemanager_library (maker, model) VALUES(NEW.maker, NEW.vmodel);

    INSERT INTO wq6vt_vehiclemanager_library_data (co2_class) 
      SELECT co2_class FROM wq6vt_vehiclemanager_vehicles
      WHERE maker = NEW.maker AND vmodel = NEW.vmodel;   
END $$
DELIMITER;

The first query in the trigger do not lead to errors, but second one does. There is some problem with SELECT inside of INSERT ...I think so

Upvotes: 1

Views: 121

Answers (1)

John Woo
John Woo

Reputation: 263723

there should be a space between the keyword and the symbol,

DELIMITER ;
      -- ^  space in between here

Upvotes: 2

Related Questions