Search code examples
mysqleclipsetriggerssyntax-erroreclipse-dtp

Eclipse DTP still doesn't handle delimiter statements


This

use sample_db;

CREATE TRIGGER bar_in
BEFORE INSERT ON bar
FOR EACH ROW
BEGIN
     DECLARE foo INT;

END;

fails with

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 5

How to solve this syntax error (MySQL server is 5.5)?

is it possible that triggers are disabled or some such?

EDIT: This is a problem with Eclipse DTP existing since 2009, bugzilla


Solution

  • I believe the error was related to the delimiter. Try this:

    DELIMITER $$
    
    CREATE TRIGGER bar_in
    BEFORE INSERT ON bar
    FOR EACH ROW
    BEGIN
         DECLARE foo INT;
    END $$ 
    
    DELIMITER ;